
2008-6-14 12:57
openear
求教一个字符串处理的函数(VB)
最近用VB6开发个小程序,需要处理这样的情况:
strA="ASDFGHJKLQ"
一个有序的(并非自然的字母顺序)、不重复的字符串
strB="DGKLQ"
所有字符都包含于strA、不重复;某种意义上讲,算strA的一个子集
求字符串:strC
strC="ASFHJ"
从strA中去除strB中出现过的字符,所剩余的字符串,保留原来顺序不变
请问有没有这样的函数:strC = function1(strA,strB)?
如果没有,请推荐一个效率较高的子程序。
谢谢!
2008-6-14 14:27
openear
Dim strA As String, strB As String, strC As String
Dim i As Integer
strA = "ASDFGHJKLQ"
strC = strA
strB = "DGKLQ"
For i = 1 To Len(strB)
strC = Replace(strC, Mid(strB, i, 1), "")
Next i
暂时就用它了。
期待更好的方法。
2008-6-14 20:44
showmetheway
不会VB,呵呵,up
2008-6-15 21:00
smthgdin
c# code:
stra.replace(stra.substring(stra.indexof(strb),strb.length),"");
replace函数中用“”代替stra.substring(stra.indexof(strb),strb.length)
vb code 参考一下。
页:
[1]

Powered by ITPUB论坛