Click to See Complete Forum and Search --> : String in text related
AndyK
December 16th, 1999, 07:31 PM
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
Chris Eastwood
December 17th, 1999, 03:02 AM
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
Ravi Kiran
December 17th, 1999, 03:17 AM
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
AndyK
December 17th, 1999, 07:34 PM
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.