|
-
October 28th, 1999, 05:47 PM
#1
Please Help
How can I by pressing command button select (highlight) specific word in text1 ?????
-
October 28th, 1999, 11:16 PM
#2
Re: Please Help
AndyK,
What I understood from your question is that you want to high light a specific word in a text box. If that is the case, I am giving you the code.
To test the code, I have drawn a text box and a comamnd button. I type a long text in text box and then click the command button and through an input box, I try to find a word typed in input box in text box. If the word is found, computer high lights the word in text box. You can modify, as per your requirements -
private Sub Command1_Click()
Dim Search, Where ' Declare variables.
' get search string from user.
Text1.SetFocus
Search = InputBox("Enter text to be found:")
Where = InStr(Text1.Text, Search) ' Find string in text.
If Where then ' If found,
Text1.SelStart = Where - 1 ' set selection start and
Text1.SelLength = len(Search) ' set selection length.
else
MsgBox "string not found." ' Notify user.
End If
End Sub
I hope this will solve the problem. In case of problem, Please let me know.
Santulan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|