Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Textbox length in characters?

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
guadalupe
Asked:
guadalupe
1 Solution
 
stevesmCommented:
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
 
RenesCommented:
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
 
clifABBCommented:
If you're looking for the number of characters, use the Len() function:
nNumChars = Len(Text1.Text)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now