CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Please Help

  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Please Help

    How can I by pressing command button select (highlight) specific word in text1 ?????


  2. #2
    Join Date
    Aug 1999
    Location
    India-Delhi
    Posts
    106

    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
  •  





Click Here to Expand Forum to Full Width

Featured