|
-
Aug 11th, 2000, 09:51 AM
#1
Thread Starter
Lively Member
Uhm, this is probably a silly question but....how would I make so that when a textbox gets the focus; if there is any text, it gets highlighted by the cursor. Thanks in advance.
-Jack Vinitsky
-
Aug 11th, 2000, 09:53 AM
#2
Junior Member
I think its something like this:
Text1.selstart = 0
Text1.sellenght = len(text1.text)
-
Aug 11th, 2000, 09:53 AM
#3
Fanatic Member
Code:
Private Sub txtName_GotFocus()
txtName.SelStart = 0
txtName.SelLength = Len(txtName.Text)
End Sub
Iain, thats with an i by the way!
-
Aug 11th, 2000, 10:12 AM
#4
Thread Starter
Lively Member
Thanks fot the help. Do I have to paste that in the got_focus event of each of text box on my form or is there another place I can put it so that it affects all of them?
-Jack Vinitsky
-
Aug 11th, 2000, 10:27 AM
#5
You would probably have to put that in all of them, unless you want to put it in a function instead.
-
Aug 11th, 2000, 10:37 AM
#6
Thread Starter
Lively Member
Thanks for all the help.
-Jack Vinitsky
-
Aug 11th, 2000, 12:31 PM
#7
Addicted Member
Actually, I've tackled this same problem you have, and if you have a lot of textboxes & multiple forms, here is one solution:
1. Array all the textboxes
2. Create the following sub: (if you put this in a module it will work for all your forms)
Public Sub Highlight()
'This highlights the text in the active textbox
With Screen.ActiveForm
If (TypeOf .ActiveControl Is TextBox) Then
.ActiveControl.SelStart = 0
.ActiveControl.SelLength = Len(.ActiveControl)
End If
End With
End Sub
3. Then in the GotFocus Event:
Textbox_GotFocus(Index as Integer)
Call Highlight
End Sub
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
|