tch001$_$1$$$10,tch002$_$2$$$10,tch002$_$3$$$10,tch002$_$3$$$11
如查找tch002$_$3,如果有两个,就用tch002$_$3$$$11替换tch002$_$3$$$10,请各位大哥指点
如查找tch002$_$3,如果有两个,就用tch002$_$3$$$11替换tch002$_$3$$$10,请各位大哥指点
解决方案 »
- CE检测到没有采用内存偏移,为何每次重启这个游戏,内存的地址都改变?
- 好无聊 散分
- 谁有PrintGrid打印预览控件V1.26 注册码? 谢了,发一个
- 请问水晶报表中运行时的右键可以屏蔽吗?
- 一个打印问题,没搜到和我一样的问题,请进来看一下吧
- 如何屏蔽掉ACTIVEBAR的右键弹出自定义窗口?
- with ---end with 是什么语句?
- 有没有获得光标底部坐标的API
- 怎么给一个按钮和Text控件定义快捷键?使其快速得到焦点?
- 大事不好,用DAO的CREATEDATABASE生成的ACCESS数据库,用jet 4.0和ADODC和DATAGRID1访问,DATAGRID中总是没内容,但ADODC中有RECORDSET记录,我怀疑是微软的问题。能帮我确定么?
- 如何将窗口置顶,但同时不需要具有焦点
- 如何在VB中把Excel单元格设置成文字
Dim S, S1 As String
Dim P, P1 As IntegerS = "tch001$_$1$$$10,tch002$_$2$$$10,tch002$_$3$$$10,tch002$_$3$$$11'"
P = InStr(S, "tch002$_$3")
If P > 0 Then
P1 = InStr(P + 10, S, "tch002$_$3")
If P1 > 0 Then
S1 = Replace(S, "tch002$_$3$$$10", "tch002$_$3$$$11")
End If
End If
MsgBox S1
End Sub
Private Sub Command1_Click()
Dim s As String, s1 As String
Dim m%, n%, n1%
s = "tch001$_$1$$$10,tch002$_$2$$$10,tch002$_$2$$$10"
Label1.Caption = s
m = Len(s)
n = Len("tch002$_$2$$$10")
n1 = InStr(s, "tch002$_$2$$$10")
If n1 <> 0 Then
s1 = Right(s, m - (n1 - 1 + n))
If InStr(s, "tch002$_$2$$$10") <> 0 Then
s = Replace(s, "tch002$_$2$$$10", "tch002$_$2$$$11")
MsgBox "字符串替换成功"
End If
Else
MsgBox "字符串不存在"
End If
Label2.Caption = s
End Sub这是把符合要求的全部替换
Option ExplicitSub Main()
Debug.Print Normalize("tch001$_$1$$$10,tch002$_$2$$$10,tch002$_$3$$$10,tch002$_$3$$$11")
Debug.Print Normalize("tch001$_$1$$$10,tch002$_$2$$$10,tch002$_$3$$$10,tch002$_$3$$$11,tch001$_$1$$$99")
End SubFunction Normalize(ByVal s As String) As String
Dim a() As String, b() As String, values As Collection, i As Long
a = Split(s, ",")
Set values = New Collection
For i = UBound(a) To 0 Step -1
b = Split(a(i), "$$$")
a(i) = b(0) 'Key
On Error Resume Next
'建立 Key-Value 对应关系,相同的 Key 只有最后第一个的 Value 可以添加到集合中
values.Add b(1), b(0)
On Error GoTo 0
Next
For i = UBound(a) To 0 Step -1
a(i) = a(i) & "$$$" & values(a(i))
Next
Normalize = Join(a, ",")
End Function