I am stuck again! Can anyone help me with this... I am looking for a way in VB to tell me what position the cursor is at in a textbox. Can I do it through the KeyPress event? If so, can somone help me? :)
Printable View
I am stuck again! Can anyone help me with this... I am looking for a way in VB to tell me what position the cursor is at in a textbox. Can I do it through the KeyPress event? If so, can somone help me? :)
The Keypress event won't do, for 2 reasons:
1) the keypress event involkes before the character is actually added to the text
2) the keypress event wont fire when you press the arrow buttons
An alternative is the Keyup event. When the event fires, check for the selstart property.
Also make sure to do the same in the click event
private Sub Text1_Click()
Label1.Caption = Text1.SelStart
End Sub
private Sub Text1_KeyUp(KeyCode as Integer, Shift as Integer)
Label1.Caption = Text1.SelStart
End Sub
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook