[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how do i restrict user not to type more than 5 lines in RTFBox

Posted on 2003-11-11
5
Medium Priority
?
158 Views
Last Modified: 2010-05-03
how do i restrict user not to type more than 5 lines in RTFBox. I am using SendMessage API method (in keypress event), which returns me nos. of line but when i press any key at the end of fifth line, it wrap the last word on sixth line, this is only the problem, otherwise it works fine.

It is very urgent, any help, idea, or clue will be highly obliged. Thanks in advance.
0
Comment
Question by:nirmal_4194
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9721673
Does
Keyascii = 0
not work (as in a standard textbox?)
0
 

Author Comment

by:nirmal_4194
ID: 9738183
Yes it works, but by the time the last word jumps to 6th line.

Can you give me coding which you have tested.

Thanks for response.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9738687
Good point.

This is tested:

Private Sub RTB_Change()
    Do While RTB.GetLineFromChar(Len(RTB.Text)) > 5
        RTB.Text = Left$(RTB.Text, Len(RTB.Text) - 1)
    Loop
End Sub

It needs a loop, because if the user enters a wide character not at the end of the fifth line, then more than one narrow character might be displaced on to the next line.
0
 

Author Comment

by:nirmal_4194
ID: 9873044
No it does not work. Please test it again, i am desparately need help.

Thanks for quick response
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 40 total points
ID: 9873286
I can find an error, but it is a simple one. The line numbers returned by the function GetLineFromChar() start at 0, so that line number 5 is actually the 6th line.
If you change the 5 to a 4, it will work,  limiting the entry to 5 lines rather than 6 lines, as my original code does.
Because this was so simple, it may be that I haven't understood the problem that you were having with the code. If so can you explain what happens?
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question