View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\)[_885_] Rick Rothstein \(MVP - VB\)[_885_] is offline
external usenet poster
 
Posts: 1
Default TextBox Question

As you know, Tab'bing into the TextBox automatically highlights (selects)
the text by default so that the user can type over (replace) it or click
into it to edit it. You can make a mouse click into the TextBox do the same
thing... will that be acceptable? If so, copy/Paste the following code into
your UserForm's code window...

'*************** START OF CODE ***************
Dim ClickedOnceAlready As Boolean

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ClickedOnceAlready = False
End Sub

Private Sub TextBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Not ClickedOnceAlready Then
ClickedOnceAlready = True
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
End With
End If
End Sub
'*************** END OF CODE ***************

Rick


"Jim" wrote in message
...
Control Toolbox In VB - A UserForm

"Rick Rothstein (MVP - VB)" wrote:

Where did you get the TextBox from? The Drawing Toolbar on the worksheet?
The Control Toolbox toolbar on the worksheet? The Control Toolbox in the
VB
editor for placement on a UserForm?

Rick


"Jim" wrote in message
...
How do I put text in a textbox and make it go away as soon as the user
clicks
in the field to enter their own information? I know how to put text in
the
field but you have to highlight it and delete it if you want to enter
new
information.