Solved

Textbox length in characters?

Posted on 1998-06-08
3
213 Views
Last Modified: 2013-12-03
In VB5, how can you get an integer which represents the length, in chracters, of a textbox even if it is empty.
The  widthproperty is in twips (which I have been roughly translating to 1/100 + 3 to get characters, but its
rough) and the TextLength Function is only for the lenght of  actual text (written characters).
- Thanks, This is a great service!!!!
0
Comment
Question by:guadalupe
3 Comments
 
LVL 1

Expert Comment

by:stevesm
ID: 1462849
Do you know which font,point size,bold,italic,etc. If so try using an "X" as an example in your text box, because of the variations in different fonts its too difficult to judge how many characters will fit into a text box. If you use X as an example you will be able to determine the maximum number of characters that you can use.

Regards Steve
0
 

Accepted Solution

by:
Renes earned 50 total points
ID: 1462850
With textwidth you can measure the with of text. Two examples:windowrect2.left = frmMain.TextWidth(left$(Currentline.Text, Charpos - letters)) + 1
               windowrect2.right = windowrect2.left + frmMain.TextWidth(word)
with these functions I can get the position of a word in a sentence (I use it to spellcheck like in MSWord and put ~~~~ under a misspelled word.)
The With is expressed in the scalemode setting, so if the form is in twips, the measures are also in twips
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1462851
If you're looking for the number of characters, use the Len() function:
nNumChars = Len(Text1.Text)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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