|
-
Nov 8th, 1999, 03:42 AM
#1
Thread Starter
Hyperactive Member
I have a text box which contains some text that is purely to help clarify what the box is for. It is meant to be replaced by the user, and so what I would like to do is have text be selected so that the user can just start typing and it will automatically replace that text. How can I do this?
------------------
Ryan
[email protected]
ICQ# 47799046
-
Nov 8th, 1999, 03:48 AM
#2
Fanatic Member
Try this:
Code:
Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
End Sub
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-08-1999).]
-
Nov 8th, 1999, 04:01 AM
#3
Hyperactive Member
For easier use, make one single subroutine:
Code:
Sub txtSelectAll(txtBox As TextBox)
With txtBox
.SelStart = 0
.SelLength = Len(txtBox.Text)
End With
End Sub
and place txtSelectAll Screen.ActiveControl in each text boxes GotFocus event. For example:
Code:
Private Sub Text1_GotFocus()
txtSelectAll Screen.ActiveControl
End Sub
Private Sub Text2_GotFocus()
txtSelectAll Screen.ActiveControl
End Sub
After a while, you will get sick of writing:
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
in each text box, and then have to change Text1 to Text2 and etc. The code I have provided will save you time, but please note this will only work with text boxes.
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470
AIM: TomY10
PERL, JavaScript and VB Programmer
-
Nov 8th, 1999, 04:04 AM
#4
Thread Starter
Hyperactive Member
Thanks, that worked perfectly! Hey, I was just wondering, what is PolComSoft???
------------------
Ryan
[email protected]
ICQ# 47799046
-
Nov 8th, 1999, 04:06 AM
#5
Fanatic Member
You will find out soon
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
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
|