Dim i As Integer, hitta As String
hitta = "din söksträng"
i = InStr(1, Text1.Text, hitta)
If i > 0 Then
Text1.SelStart = i
Text1.SelLength = Len(hitta)
Text1.SetFocus()
Else
MsgBox "Texten " & hitta & " kunde inte hittas", vbCritical
End If
koden funkade i det stora hela men jag fick bort dom här () vid text1.setfocus och då funkade det.
markeringen markerade inte hela ordet. så jag gjorde så här så att det skulle funka att markera hela ordet:
Dim i As Integer, hitta As String
hitta = "din söksträng"
i = InStr(1, Text1.Text, hitta)
If i > 0 Then
Text1.SelStart = i - 1
Text1.SelLength = Len(hitta)
Text1.SetFocus()
Else
MsgBox "Texten " & hitta & " kunde inte hittas", vbCritical
End If