Click to See Complete Forum and Search --> : Text Box Property?


Apprentice
July 13th, 2001, 05:08 PM
I have a series of small text boxes that I'm using to enter numerical data on a form. I want to be able to change the data quickly as I tab through them, so I'm looking for a way to have the text automatically highlight when it's text box recieves the focus. How can I do this?

Thank you for all your help.





The more you know, the more you know you don't know.

michi
July 13th, 2001, 05:52 PM
Private Sub txtYourTextBox_GotFocus()
txtYourTextBox.SelStart = 0
txtYourTextBox.SelLength = Len(txtYourTextBox.Text)
End Sub


Regards,

Michi
MCSE, MCDBA

Apprentice
July 13th, 2001, 06:26 PM
Ummm... That sort of worked. It highlighted the contents of the text boxes alright, but it won't let me enter more than one integer now, because the content is continually highlighted. Is that because I'm using the GotFocus event? hmmm... any ideas?





The more you know, the more you know you don't know.

Apprentice
July 13th, 2001, 06:31 PM
Nevermind. I made a stupid mistake. I had it set to the Change event instead of GotFocus. That code works just fine. Thank you.





The more you know, the more you know you don't know.

michi
July 13th, 2001, 06:33 PM
It works fine for me. I guess maybe the MaxLength property of this TextBox is set to 1. If so, try to change it to 0 or whatever you want.

Regards,

Michi
MCSE, MCDBA