First time I've ever _answered_ a question!
I got this code for finding the number of lines in a text box from a kind helper
on this newsgroup a few months ago -
This bit goes in the form declarations section...........
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_GETLINECOUNT = &HBA
This is a function on the form or in a basic module......
Public Function fnfindnooflines()
fnfindnooflines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
End Function
And if at anyplace in your code you want the number of lines, just write.....
numberoflines = fnfindnooflines
and magically, the integer 'numberoflines' takes on the value of the number of
lines in the box!
Does setting 'text1.Selstart' to some value move the cursor to that position in
the text on the text box? But how are you to be sure it has moved to a different
line? Only if you know where the line starts and where it ends. You can actually
get the individual lines using API as my helper showed me, although I ended up
sticking to a toruous code method I'd invented previously.
The maximum number of characters depends on the font, the width of the box, and
which characters they are. If the box has a width of 500, you can presumably get
10 characters of width 50 in it (don't ask me what the units are - Twips
perhaps).
Quote:
> Hi all! I have 4 questions that i cant find any info on..
> 1. How do i determine the number of lines in a textbox?
> 2. And how do i count the number of chars in in the textbox?
> 3. What is the maximum number of chars on every line in a textbox?
> 4. How do i move the scrollbar in a textbox, eg placing the cursor somewhere
> else, on another line?
> Thanks for any help!
> /Timh
> Just remove NOSPAM in the email to answer me direct.