ansi
April 24th, 2001, 03:13 AM
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? :)
|
Click to See Complete Forum and Search --> : Stuck again! ansi April 24th, 2001, 03:13 AM 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? :) Cakkie April 24th, 2001, 04:46 AM 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 slisse@planetinternet.be 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |