Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cursor position in masked edit box

Status
Not open for further replies.

mogwaicat

Programmer
May 8, 2001
14
0
0
US
How do I get the cursor to go to the first position in my masked edit box no matter where I click in the edit box? I tried this in GotFocus: mskEdBox.selstart=0 (zero) and it doesn't seem to work. Thanks...
 
It should work the first time, when the masked edit box originally gets focus. It's not going to work if focus is already on the masked edit box and you click again.
 
mogwaicat,

Try the Click event instead of the GotFocus.

I think I got it to do what you want. Try the Click instead.

-crater
 
hmmm...I don't know. I tried the following and it worked just fine.


Private Sub mskTest_GotFocus()
mskTest.SelStart = 0
End Sub


I am using VB6 and the mask was ##-##-####. It would put me at the first position no matter where I clicked.
 
to SmokingCrater: There isn't a "click" event for a masked edit box control.
 
mogwaitcat,

Sorry. My mistake. Looking at the wrong control.

Darn. You're right. That control is bad. I tried placing an invisible label over the top to try to utilize the Click event from a label but that didn't work either. Perhaps you need to write one. Using a TextBox and watching the Click event and the KeyPress even will allow you to control the user input and keep it in the correct place.

Unfortunately, I agree with jitter. I've also got VB6 and the version on my OCX is SP3. That worked fine for me. When you click on the object the first time, it scrolls to the front. So unfortunately, I've got no other ideas. Sorry. :(

-crater
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top