vb编程编写一个函数,删除一个字符串中的特定字符
展开全部
'定义一个find函数
Private Function find(s1 As String, s2 As String) As String
Dim i As Integer
For i = 1 To Len(s1)
If i = InStr(1, s1, s2, vbTextCompare) Then
find = Left(s1, i - 1) & Right(s1, Len(s1) - Len(s2) - i + 1)
Exit Function
End If
Next i
find = s1
End Function
'将Text1.Text中的Text2.Text字符删除
Private Sub Command1_Click()
Dim s As String
s = find(Text1.Text, Text2.Text)
Text1.Text = s
End Sub
Private Function find(s1 As String, s2 As String) As String
Dim i As Integer
For i = 1 To Len(s1)
If i = InStr(1, s1, s2, vbTextCompare) Then
find = Left(s1, i - 1) & Right(s1, Len(s1) - Len(s2) - i + 1)
Exit Function
End If
Next i
find = s1
End Function
'将Text1.Text中的Text2.Text字符删除
Private Sub Command1_Click()
Dim s As String
s = find(Text1.Text, Text2.Text)
Text1.Text = s
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询