Highlight Value of Text Box

G

Guest

I have a UserForm with four textboxes names py1 py2 py3 py4
What I am trying to accomplish is that when a user clicks into a textbox, it
will loop through the other three add their values and subtract it from a
Total, and put that value into the textbox. This part I have accomplished
with no problem.
However when it puts that value into the textbox the user has clicked into i
want to HIGHLIGHT the value that was entered into textbox through VBA

..selstart & .sellength will not select it code follows


Private Sub py1_Enter()
Dim t As Integer
toy = 0
Set ctl1 = Me.ActiveControl
For t = 1 To 4
Set ctll = Me.Controls("py" + Trim(Str(t)))
If ctl1.Name <> ctll.Name Then toy = toy + Val(ctll.Text)
Next
With ctl1
..Text = Trim(Str(tow - toy))
..SelStart = 0
..SelLength = Len(.Text)
End With
End Sub

the code is EXACTLY the same for each text box
the two variables ctll & ctl1 are public in the userform.
anyone see why maybe the userform will not highlight the text?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top