Using lines propery of rtb, i found a way to navigate thru all lines using lines array. but i am not able to select the string that i am looking for.
string is found in say line 573, but how can i select just that string?
rtb.select(??, len(string) .. dont know how to set the startpos in select property.
i add length of each lines to get the start but unfortunately it doesnt return the correct .
divil, can you help me?
---------------heres my function----------------------
Function locate_string2(ByVal search_string As String) As Boolean
Dim counter As Integer
Dim temparray() As String
Dim comment_start As Boolean
Dim tot_char As Integer
temparray = RichTextBox1.Lines
For counter = 0 To temparray.GetUpperBound(0)
If InStr(temparray(counter), "/*") > 0 Then
comment_start = True
GoTo nextfind
End If
If InStr(temparray(counter), search_string) > 0 Then
MsgBox("foundit")
End If
If InStr(temparray(counter), "*/") > 0 Then comment_start = False
If InStr(temparray(counter), search_string) > 0 And comment_start = False Then
If InStr(temparray(counter), "//") > 0 Then comments line
If InStr(temparray(counter), "//") < InStr(temparray(counter), search_string) Then
GoTo nextfind
End If
ElseIf InStr(temparray(counter), "/*") > 0 Then comments line
If InStr(temparray(counter), "/*") < InStr(temparray(counter), search_string) Then
GoTo nextfind
End If
Else
If Trim(temparray(counter)) <> "" Then
RichTextBox1.HideSelection = False
RichTextBox1.Select(tot_char + InStr(temparray(counter), search_string), Len(temparray(counter)))
Return True
End If
End If
End If
nextfind:
tot_char = tot_char + Len(temparray(counter))
Next
End Function