Solved

Textbox length in characters?

Posted on 1998-06-08
3
212 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

895 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

13 Experts available now in Live!

Get 1:1 Help Now