Textbox question.. 
Author Message
 Textbox question..

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.



Tue, 11 May 2004 17:14:28 GMT  
 Textbox question..
http://www.mvps.org/vbnet/


Fri, 23 Nov 2001 09:14:28 GMT bearing the following fruit:

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.



Tue, 11 May 2004 17:42:37 GMT  
 Textbox question..
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?
==============

Sounds like you're trying to make a textbox into something it's not.
Add the richtx32.ocx control to your toolbox and use it instead. I
think you'll find that it does all of the things you're looking for.

And if you're counting characters and spaces, just use the Len
function. But if you're counting so you can add to a database, you
might want to include the formatting characters also.
-Murf



Wed, 12 May 2004 23:15:38 GMT  
 Textbox question..
No - this does not sound like the RichText box to me.

The OP needs to look at the Win APIs - specifically the EM_ messages

Personally I would 'wrap' the thing in a UserControl

To use a RichText box unnecessarily would violate a principle that I
believe is essential - 'never use an OCX if you can possibly avoid it'


Quote:
>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?
>==============

>Sounds like you're trying to make a textbox into something it's not.
>Add the richtx32.ocx control to your toolbox and use it instead. I
>think you'll find that it does all of the things you're looking for.

>And if you're counting characters and spaces, just use the Len
>function. But if you're counting so you can add to a database, you
>might want to include the formatting characters also.
>-Murf



Thu, 13 May 2004 19:18:59 GMT  
 Textbox question..
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.



Fri, 14 May 2004 22:03:41 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. TextBox question

2. vb.net textbox question

3. Textbox questions

4. textbox question

5. textbox question

6. NewBee VB5 textbox question

7. tough textbox question

8. ..easy textbox question from a newbie

9. Newbie TextBox question

10. Easy Textbox Question ?

11. TextBox Question

12. Textbox Question

 

 
Powered by phpBB® Forum Software