Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / January 2008



Tip: Looking for answers? Try searching our database.

Get line length in textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ed - 07 Jan 2008 19:03 GMT
The code below always returns the length of the first line of text in a
textbox under Windows XP.

Function GetLineLen(txt As TextBox, line As Long) As Long
GetLineLen = SendMessage(txt.hwnd, EM_LINELENGTH, ByVal line, ByVal 0&)
End Function

What should I be using for Windows XP?

Thanks,
Ed
Scott Seligman - 07 Jan 2008 19:37 GMT
>The code below always returns the length of the first line of text in a
>textbox under Windows XP.
>
>Function GetLineLen(txt As TextBox, line As Long) As Long
> GetLineLen = SendMessage(txt.hwnd, EM_LINELENGTH, ByVal line, ByVal 0&)
>End Function

Untested code:

Function GetLineLen(txt As TextBox, line As Long) As Long
   Dim lineindex As Long
   lineindex = SendMessage(txt.hwnd, EM_LINEINDEX, ByVal line, ByVal 0&)
   GetLineLen = SendMessage(txt.hwnd, EM_LINELENGTH, ByVal lineindex, ByVal 0&)
End Function

Signature

--------- Scott Seligman <scott at <firstname> and michelle dot net> ---------
  Bodily exercise, when compulsory, does no harm to the body; but
  knowledge which is acquired under compulsion obtains no hold on the
  mind. -- The Republic by Plato

Ed - 07 Jan 2008 20:44 GMT
>Untested code:
>
[quoted text clipped - 3 lines]
>    GetLineLen = SendMessage(txt.hwnd, EM_LINELENGTH, ByVal lineindex, ByVal 0&)
>End Function

Did quick test and seems to be working fine!

Thanks,
Ed
MikeD - 09 Jan 2008 00:56 GMT
> The code below always returns the length of the first line of text in a
> textbox under Windows XP.
[quoted text clipped - 4 lines]
>
> What should I be using for Windows XP?

Good thing Scott understood what you meant.  <g>

Signature

Mike
Microsoft MVP Visual Basic

Ed - 09 Jan 2008 19:16 GMT
>Good thing Scott understood what you meant.  <g>

I thought the subject made it pretty clear? ;)
MikeD - 10 Jan 2008 02:29 GMT
>>Good thing Scott understood what you meant.  <g>
>
> I thought the subject made it pretty clear? ;)

Yes, it was clear he wanted the line length, but take another look at what
he wrote:

> The code below always returns the length of the first line of text in a
> textbox under Windows XP.
>
> What should I be using for Windows XP?

I guess I found the 2 references to Windows XP to be confusing. Possibly
just me.

Signature

Mike
Microsoft MVP Visual Basic

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.