find textbox insertion point

B

Bert

Is there a way to test for the current insertion point in a Userform
textbox--if, for example, there are 100 characters in the textbox, and the
user clicks at a point in the textbox, is there a way to find out where in
the string the user has clicked.
Thanks.
 
J

JLGWhiz

Look at the SelStart Property in VBA help. I think that is what you are
looking for.
 
P

Peter T

Private Sub TextBox1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
With TextBox1
Me.Caption = .CurLine & " " & .SelStart & " " & .SelLength
End With
End If
End Sub

Regards,
Peter T
 
B

Bert

Thanks...that's exactly what I need.

Peter T said:
Private Sub TextBox1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 1 Then
With TextBox1
Me.Caption = .CurLine & " " & .SelStart & " " & .SelLength
End With
End If
End Sub

Regards,
Peter T
 

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