Advertisement
C_Volume2 Miscellaneous #74416

Search a String and Highlight (SrchString)

This source code will search for a certain string from a TextBox (can be modified to search from any string-bearing control, etc.). Once the string is found, a message box will appear letting you know that the string was found, and then the string will be highlighted.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'Text2 is the TextBox to search for the string in.
Dim I as Integer
Private Sub Command1_Click()
 For I = 1 To Len(Text2)
  If Mid(Text2, I, Len(Text1)) = Text1 Then
   MsgBox "String located and highlighted."
   Text2.SetFocus
   Text2.SelStart = I - 1
   Text2.SelLength = Len(Text1)
  End If
 Next I
End Sub()
Original Comments (3)
Recovered from Wayback Machine