VB6.0 查找文本 替换文本 问题

来源:百度知道 编辑:UC知道 时间:2024/05/17 02:03:58
这道题我研究半天了,题是这样的。
有三个文本框分别是text1 ,text2, text3,还有一个按钮cmd1

要做的是在text1里输入 文字 字母 数字 等后 在text2中输入text1里有的文字 字母或数字,然后按cmd1按钮 text1中的内容(与text2中输入的相同的)便与text3中新输入的 内容替换了 。

这个程序怎么编啊 各位大大帮帮忙啊!! 小弟 在此谢谢了
我已经写出来了 谢谢各位了!!

Private Sub Command1_Click()
Dim s1, s2 As String
Dim i, n As Integer
n = Len(Text2.Text)
If n <= Len(Text1.Text) Then
For i = 1 To n
If Mid(Text1.Text, i, n) = Text2.Text Then
s1 = Left(Text1.Text, i - 1) & Text3.Text & Right(Text1.Text, Len(Text1.Text) - i - 1)
Text1.Text = s1
End If
Next i
End If
End Sub

cmd1里写
text1=replace(text1,text2,text3)