View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_143_] Leith Ross[_143_] is offline
external usenet poster
 
Posts: 1
Default Highlight all Text in a Textbox when the textbox is selected


Hello RPIJG,

If you want to highlight the text inside a TextBox on a user form whe
the user clicks the TextBox, this code will do that.

Inset this code into the Mouse_Up Event for the TextBox. Chang
TextBox1 in the Example to match the name of your TextBox.


Code
-------------------
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With

End Sub

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48018