-
whats wrong
i tried a lot to get rid of the errors but i could'nt
please help me ' the error its giving is 'type missmatch'
Private Sub cmdFindNext_Click()
On Error GoTo error_handler
Dim position As long
Dim str1 As String
Dim str2 As String
str1 = frmEDITOR.rtbEditor.Text ' main form's text box(richtext box)
str2 = txtfind.Text 'just a text box
If chkMcase = vbChecked Then
position = InStr(str1, str2, vbBinaryCompare)
Else
position = InStr(str1, str2, vbTextCompare)
End If
Exit Sub
error_handler:
MsgBox Err.Description
End Sub
-
First of all uncomment your On Error statement, and see which line causes the error.
-
Code:
Dim position As Long
Dim str1 As String
Dim str2 As String
str1 = "blah testing this out"
str2 = "testing"
position = InStr(1, str1, str2, vbBinaryCompare)
Debug.Print position
InStr([start],[string1],[string2],[Compare as VbCompareMethod])
You didn't give it a starting place in the InStr.
-
Hi,
if the type of compare is specified you have to say where he must start.
So use:
If chkMcase = vbChecked Then
position = InStr(1, str1, str2, vbBinaryCompare)
Else
position = InStr(1, str1, str2, vbTextCompare)
end if
Greetings.:)
-
Seem's like we posted on the same time rebelDev.