Solved

Textbox length in characters?

Posted on 1998-06-08
3
211 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
Comment Utility
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
Comment Utility
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
Comment Utility
If you're looking for the number of characters, use the Len() function:
nNumChars = Len(Text1.Text)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now