View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Jim Jim is offline
external usenet poster
 
Posts: 615
Default TextBox Question

Thanks, I modified it a little to just delete what text was already there.
Really appreciate it. thanks again

'*************** 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
TextBox1.value = ""
End With
End If
End Sub
'*************** END OF CODE ***************





"Rick Rothstein (MVP - VB)" wrote:

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.