|
-
Jun 18th, 2003, 10:25 AM
#1
Thread Starter
Lively Member
Moving cursor within a combo box
Hello. I have a VB6 app that, when a user opens a form the focus is on a drop-down. If they hit the space bar (an invalid entry) it slaps their hand with a message box and makes them re-enter. The only problem is that once the message box closes the cursor is in the second position within the combo box. I'm still looking, but I'm not finding how to reset the cursor to the first position.
Thanks!
Ed
-
Jun 18th, 2003, 10:29 AM
#2
-
Jun 18th, 2003, 10:35 AM
#3
Thread Starter
Lively Member
Thank you! But, I must be doing something wrong... here's how I integrated the line above:
VB Code:
If KeyAscii = 32 Then
MsgBox ("Cannot begin search with a space")
Me.cboChooseHospital.SelStart = 0
Exit Sub
End If
After the msgbox is cleared, the cursor stays in the second position. Should the SelStart be in a sub procedure?!
Thank you for your quick response!!!
Ed
-
Jun 18th, 2003, 10:38 AM
#4
Try this :
VB Code:
If KeyAscii = 32 Then
MsgBox ("Cannot begin search with a space")
KeyAscii = 0
Me.cmbHospital.SelStart = 0
Exit Sub
End If
Has someone helped you? Then you can Rate their helpful post. 
-
Jun 18th, 2003, 10:41 AM
#5
Thread Starter
Lively Member
Whoo Hooo! That's it!! ¡Buenísimo!
Now the cursor goes right back to the initial position!!
Thanks everyone for your help!!!
Ed
-
Jun 18th, 2003, 10:41 AM
#6
yeah i was puzzled for a min.. then remembered that it doesn't actually send the key to the control until the sub ends...
on a side note... it isn't really the best idea to pop up a message box when a user hits a space.. it is better to
1) do it on the lost focus event of the control
2) manually remove any spaces the user does enter
3) do it how you have it now.. but without the msgbox
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|