主题:为什么执行后无结果?
编写一个sub过程,将字符串s1中出现的子符串s2删除,结果仍保存在s1中。可是按书上的写出来,为什么执行后没有结果?是哪里不问题了?
Option Explicit
Private Sub delestr(s1 As String, ByVal s2 As String)
Dim position As Integer, s1length As Integer, s2length As Integer
position = InStr(s1, s2)
s2length = Len(s2)
Do While position > 0
s1length = Len(s1)
s1 = Left(s1, position - 1) & Right(s1, s1length - (position + s2length) + 1)
position = InStr(s1, s2)
Loop
End Sub
Private Sub command_click()
Dim s1 As String
s1 = Text1.Text
Call delestr(s1, Text2.Text)
Text3.Text = s1
End Sub
Option Explicit
Private Sub delestr(s1 As String, ByVal s2 As String)
Dim position As Integer, s1length As Integer, s2length As Integer
position = InStr(s1, s2)
s2length = Len(s2)
Do While position > 0
s1length = Len(s1)
s1 = Left(s1, position - 1) & Right(s1, s1length - (position + s2length) + 1)
position = InStr(s1, s2)
Loop
End Sub
Private Sub command_click()
Dim s1 As String
s1 = Text1.Text
Call delestr(s1, Text2.Text)
Text3.Text = s1
End Sub