ok, i modified and it works but it only find only 1 line, i eed to find 2 lines, and write the 2 lines in the textbox2.
the modified code is the following:
Private Sub Command1_Click()
Dim SearchStr As String
Dim LookInStr As String
Dim arr As Variant
Dim Counter As Long
Dim ShowStr As String
LookInStr = Text1.Text
If LookInStr = "" Then
MsgBox "There is no string to search"
Exit Sub
End If
SearchStr = InputBox("What string to search for")
LookInStr = Replace(LookInStr, Chr(13), Chr(10))
arr = Split(LookInStr, Chr(10))
For Counter = LBound(arr) To UBound(arr)
If InStr(1, arr(Counter), SearchStr, vbTextCompare) > 0 Then
ShowStr = ShowStr & arr(Counter) & Chr(10)
End If
Next
ShowStr = Left(ShowStr, Len(ShowStr) - 1)
Text2.Text = ShowStr
End Sub
Main Topics
Browse All Topics





by: matthewspatrickPosted on 2005-12-06 at 08:16:04ID: 15428638
Hi matthews_30,
Try this:
Private Sub CommandButton1_Click()
Dim SearchStr As String
Dim LookInStr As String
Dim arr As Variant
Dim Counter As Long
Dim ShowStr As String
LookInStr = Me.TextBox1
If LookInStr = "" Then
MsgBox "There is no string to search"
Exit Sub
End If
SearchStr = InputBox("What string to search for")
LookInStr = Replace(LookInStr, Chr(13), Chr(10))
arr = Split(LookInStr, Chr(10))
For Counter = LBound(arr) To UBound(arr)
If InStr(1, arr(Counter), SearchStr, vbTextCompare) > 0 Then
ShowStr = ShowStr & arr(Counter) & Chr(10)
End If
Next
ShowStr = Left(ShowStr, Len(ShowStr) - 1)
Me.TextBox2 = ShowStr
End Sub
Regards,
Patrick