abenitez77
IS-IT--Management
How can I search for something in a textbox and when found, highlight the word or phrase searched. I don't want the whole textbox highlighted.
thanks,
alex
thanks,
alex
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Private Sub UserForm_Initialize()
TextBox1.Text = "Hello My World"
End Sub
Private Sub CommandButton1_Click()
Dim strSearch As String
strSearch = "My"
With TextBox1
If InStr(.Text, strSearch) Then
.SelStart = InStr(.Text, strSearch) - 1
.SelLength = Len(strSearch)
.SetFocus
End If
End With
End Sub
Private Sub Command2_Click()
Dim strSearch As String
strSearch = Me.Text0.Value
With Me.Text3
If InStr(.Text, strSearch) Then
.SelStart = InStr(.Text, strSearch) - 1
.SelLength = Len(strSearch)[blue]
Else
.SelStart = 0
.SelLength = 0
End If[/blue]
.SetFocus
End With
End Sub