Help with SendMessage API calls

S

Steve

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
 
G

Guest

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
 
C

Crouchie1998

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.
 
S

Steve

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top