Private Sub command1_Click()
   Dim Search, Where   ' 声明变量。
   ' 获取需要查找的字符串。
   Search = InputBox("Enter text to be found:")
   Where = InStr(Text1.Text, Search)   ' 在文本中查找字符串。
   If Where Then   ' 如果找到,
      Text1.SelStart = Where - 1   ' 设置选定的起始位置并
      Text1.SelLength = Len(Search)   ' 设置选定的长度。
      '------------------------------------------------
      Text1.SetFocus
      '------------------------------------------------
   Else
      MsgBox "String not found."   ' 给出通知。
   End If
End Sub