Highlighting textboxes?

10-26-2005, 11:59 AM
I am trying to highlight my textboxes, but this peice of code doesn't do it. I have searched posts for similar code and they look very similiar. I tried different ones, but nothing works. Can someone look at this and tell me what is wrong with it?

Public Sub Highlight()
With Screen.ActiveForm
If (TypeOf .ActiveControl Is TextBox) Then
.ActiveControl.SelStart = 0 'SelStart specifies the starting position
.ActiveControl.SelStart = Len(.ActiveControl)
End If
End With
End Sub
Private Sub Text1_GotFocus(Index As Integer)
End Sub

there are 4 textboxes in a control array.

10-26-2005, 12:05 PM
You are setting .SelStart twice, the 2nd one should be .SelLength, no?

10-26-2005, 12:13 PM
Additionaly to the .SelStart issue, there can only be one active control so that only one will be highlighted, probably the first in the tab order.

10-26-2005, 12:20 PM
Thanks a bunch. I don't know how that didn't puzzle me to begin with, but maybe I have stared at it too long.
Thanks again :D

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum