Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Textbox length in characters?

Posted on 1998-06-08
3
Medium Priority
?
217 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
[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 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 150 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
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…
Suggested Courses

719 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