控件查找功能提示溢出錯誤!執行階段錯誤’6‘ 溢出
SOS!在線等!!!
command3(查找);
代碼:
Private Sub Command3_Click()
Dim i As Integer
Dim strfind As String
If Trim(Text2.Text) = " " Then
MsgBox "請輸入要查找的內容 "
End If
i = 0
strfind = Trim(Text2.Text)
i = RTB.Find(strfind, 0, Len(RTB)) '====大概問題在此處
If i > = 0 Then
RTB.SelStart = i
RTB.SelLength = Len(strfind)
RTB.SetFocus
pos = i + Len(strfind)
End If
End Sub
command2(下一個)
代碼:
Private Sub Command2_Click()
Dim i As Integer
Dim strfind As String
strfind = Trim(Text2.Text)
i = RTB.Find(strfind, pos, Len(RTB))
i = RTB.Find(strfind, pos, Len(RTB)) '===大概問題在此處
If i > = 0 Then
RTB.SelStart = i
RTB.SelLength = Len(strfind)
RTB.SetFocus
pos = i + Len(strfind)
End If
End Sub
[解决办法]
RTB.Find 是否为 Long?你的 i 应该定义相同的类型