CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    String in text related

    I have a line "Select 45 //Flat"
    I used VB to find string "Select"...now how do I tell VB to select whole line which is "Select 45 //Flat" ...I can't use find "Select 45 //Flat" because 45 can be any number, so I need to select whole line (Select 45 //Flat) in textbox where that "Select" was found...how?

    Thank You





  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: String in text related

    If you've figured out how to find the 'Select' position in the text box, then getting the length of the line is quite straight forward :


    private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, _
    lParam as Any) as Long

    private Const EM_LINELENGTH = &HC1




    Say, for instance, that a variable 'lStart' has been set with the start position of the 'Select' text :


    Dim lLineLen as Long
    Dim sSelectedText as string
    '
    lLineLen = SendMessage(Text1.hwnd, EM_LINELENGTH, lStart, 0&)
    '
    sSelectedText = mid$(Text1.Text, lStart, lLineLen - lStart)




    - that should be enough to get you on the right track - you'll obviously need to change the 'text1.' to your textbox name.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

  3. #3
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: String in text related

    Lothar was once suggesting Using Scripting Runtime (if you have IE 40 or later, SCRRun.dll ? ) for this kind of Parsing/Data validatoin etc.

    You can use similar features of that model for doing this kind of 'advanced search'ing too. It will come under 'parsing logic' actually. May be you can contact him!..

    RK

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

    Re: String in text related

    OK, it does work and it does return me the selected string but why does it return string as number, I need it as value.....What should I fix....

    Thank You


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