devxlogo

Counting Lines in RichTextBox

Counting Lines in RichTextBox

Question:
I want to develop a word-processor with VB 4.0 and the RichTextBox. I’ve got all the functions like bold, italic etc. but I’m missing a function to count the pages. Is there any function in VB 4.0 to count the pages or do I have do write my own function?

Answer:
After checking the RichTextBox help, the only thing I found was the GetLineFromChar method. It tells you what line a particular character number is. You could do something like this:

Dim iLines as LongiLines = RichTextBox.GetLineFromChar(Len(RichTextBox.Text))
That should give you the total number of lines in the document. You can then divide that by 66 or however many lines there are on your page, with a given font size.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist