|
-
Jun 5th, 2000, 07:43 PM
#1
Thread Starter
New Member
What is simple code for adjusting a textbox's appearence to the length of the text enter? For example, if the person enters the name, Joe, I want the textbox to adjust its sixe to three characters. If the person's name is Alexander, I wnat the textbox to adjust its length to 9 characters.
-
Jun 5th, 2000, 07:55 PM
#2
Hyperactive Member
Hello btz3d,
Try this source:
MsgBox Len(Text1.Text)
Michelle.
-
Jun 5th, 2000, 07:58 PM
#3
Fanatic Member
In vb it is roughly 90 pixels per character for width attribute of text boxes (Providing it is the default font and size) so you could do the following to solve your problem
Code:
Private Sub Text1_Change()
Text1.Width = Len(Text1) * 90
End Sub
This Harshly does what you ask for
Hope this helps
Ian
Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!
-
Jun 5th, 2000, 08:01 PM
#4
Fanatic Member
This is independent of font. Except it seems to get it wrong, hence the + 90.
Code:
Text1.Width = TextWidth(Text1.Text) + 90
Iain, thats with an i by the way!
-
Jun 5th, 2000, 08:50 PM
#5
_______
try this out for size
Won't work in text change as noted above
Make your font and measure work togeather.
Try this out..
Private Sub Text1_GotFocus()
Text1.Text = ""
Text1.Font = "New Roman"
Text1.FontSize = "10"
Text1.Width = 2000
End Sub
Private Sub Text1_LostFocus()
Dim myText
myText = Trim(Text1.Text)
Text1.Width = Len(myText) * 80
Text1.SelStart = 0
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 5th, 2000, 09:48 PM
#6
transcendental analytic
Textwidth is a property of a picturebox or form, in this case the omitted Me keyword which should be the form within which it is used. It returns the text width of text used with the forms font so put the forms font to the textbox font first.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|