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

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default TextBox Question

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.


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

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.



  #4   Report Post  
Posted to microsoft.public.excel.misc
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.




  #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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Private Textbox Exit Sub question... [email protected] Excel Worksheet Functions 14 March 1st 07 03:58 AM
Textbox question browie Excel Discussion (Misc queries) 1 June 13th 05 11:06 PM
Textbox question browie Excel Discussion (Misc queries) 0 June 13th 05 04:00 PM
Textbox question? Greg B Excel Discussion (Misc queries) 2 June 2nd 05 03:56 PM
UserForm TextBox/ComboBox question grasping@straws Excel Discussion (Misc queries) 1 February 2nd 05 11:14 AM


All times are GMT +1. The time now is 02:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"