By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,033 Members | 1,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,033 IT Pros & Developers. It's quick & easy.

Help with SendMessage API calls

P: n/a
Hi all,

Could someone provide a link to working code examples for implementing these
Sendmessage API calls in VB.NET ??

EM_GETLINECOUNT
EM_GETLINE
EM_LINELENGTH
EM_LINEINDEX

I want to use these to get info from a multiline textbox. I can only find
VB6 examples on the net.

thanks in advance
Steve
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

The textbox has a lines property I would use that instead of sendmessage

For counter as integer = 1 to 50
textbox1.text &= "line number " & counter.tostring & controlchars.crlf
next

Dim strLines() as string = textbox1.lines

trace.writeline(string.format("Textbox lines {0}", strlines.getubound(0)))

For each sLine as string in strlines
trace.writeline(sline)
trace.writeline(string.format("Line length = {0}", sline.length))
next

Ken
--------------------
"Steve" wrote:
Hi all,

Could someone provide a link to working code examples for implementing these
Sendmessage API calls in VB.NET ??

EM_GETLINECOUNT
EM_GETLINE
EM_LINELENGTH
EM_LINEINDEX

I want to use these to get info from a multiline textbox. I can only find
VB6 examples on the net.

thanks in advance
Steve

Nov 21 '05 #2

P: n/a
If you can only find VB 6 examples then why don't you just convert them? It
would be very easy to do so.

Ken is right about the number of lines etc. so, that part doesn't need to be
converted.

Are you using a RichTextBox or a standard TextBox by the way? Just out of
interest.
Nov 21 '05 #3

P: n/a
Thankyou both,

I have now managed to convert the VB6 code with the help of a few google
searches etc. It's all working fine now. I have zero VB6 experience and only
slightly more vb.net experience, and this is my first use of API calls :P
The change from 32bit to 64bit for long ints was what caught me in the end

As for why I don't use the standard .lines property..
The lines property only splits up the text into separate strings when there
are hard CR/LF's entered by the user. I want to get an array of strings
respresenting the text as it appears in the box, with any wrapped lines
treated as separate strings.

ie if I type "hello world this is a test" and the textbox wraps it over 2
lines, the .lines property will just return a single-element array with
that one full string.
The API EM_GETLINE call returns 2 strings of "hello world" and "this is a
test" just as it appears in the box

I want it this way so I can easily dump the contents of the textbox to a
label printer as ascii

thankyou both again
Steve

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.