' Visual Basic
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
TextBox1.Text = "Two of the peak human experiences are "
TextBox1.Text = TextBox1.Text & "good food and classical music."
End Sub
Private Sub Form1_Click(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles Me.Click
Dim Search As String
Dim Where As String
' Get search string from user.
Search = InputBox("Enter text to be found:")
' Find string in text.
Where = InStr(TextBox1.Text, Search)
If Where Then
TextBox1.Focus()
TextBox1.SelectionStart = Where - 1
TextBox1.SelectionLength = Len(Search)
Else
MsgBox("String not found.")
End If
End Sub