![]() |
Highlight (ie Select characters in a textbox)
Is there a way with programming to select a certain string of characters in a
Form TextBox. For example: Lets say the TextBox's value is: "This is the example I want to use." Is there a way without using the mouse to highlight the word example in that phrase. Thank you, Steven |
Highlight (ie Select characters in a textbox)
Change the TextBox's HideSelection property to False (otherwise you would
have to set focus to the TextBox in order to see the highlight) and then use the SelStart and SelLength properties of the TextBox to highlight the text. Here is some example code... Dim Word As String Word = "example" With Me.TextBox1 .SelStart = InStr(1, .Text, Word, vbTextCompare) - 1 .SelLength = Len(Word) End With -- Rick (MVP - Excel) "Steven" wrote in message ... Is there a way with programming to select a certain string of characters in a Form TextBox. For example: Lets say the TextBox's value is: "This is the example I want to use." Is there a way without using the mouse to highlight the word example in that phrase. Thank you, Steven |
All times are GMT +1. The time now is 09:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com