View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default User form: select all text on text field entry not working

Chrisso wrote on 2/18/2011 :
All

How come this does not work on my Excel 2003 user form?

Private Sub txtStartTime_Enter()
' ### TODO - does not work!
With Me.txtStartTime
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub

Thanks in advance for any thughts,
Chrisso


Try 'SelStart = 1' since 1 is the position of the first character. If
the textbox is empty then naturally nothing will be selected, and so
you might want to wrap your code in an If..Then so execution is
conditional on there being text in that textbox.

If txtStartTime = "" Then Exit Sub '//do nothing if empty field

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc