Replace函数的第五参数表示替换次数(第四参数指替换开始处).
Private Sub Form_Load()
Dim sTemp As String
sTemp = "i am a boy 100 20 100 30"
sTemp = Replace(sTemp, "100", "50", , 1)
sTemp = Replace(sTemp, "100", "60", , 1)
MsgBox sTemp
End Sub
Str1 = "i am a boy 100 20 100 30"
strx = "100"
dim stry(2)
stry(0) = 50
stry(1) = 60
for i=1 to ubound(stry)
str1 = replace(Left(Str1, instr(Str1,strx)+len(strx)),strx,stry(i-1)) & right( Str1, len(Str1)-instr(Str1,strx)-len(strx))
next
wscript.echo str1
二楼正解
顺便请教第四参数是干嘛用的?