|
-
Feb 9th, 2000, 07:12 AM
#1
Thread Starter
Hyperactive Member
I have a text box that I don't want people to be able to tab out of. In the KeyPress event, I already tried this code:
If KeyAscii = vbKeyTab Then KeyAscii = 0
But it didn't work. It still tabs out of the textbox. I also tried:
If KeyAscii = vbKeyTab Then
KeyAscii = 0
Cancel = 1
End If
And
If KeyAscii = vbKeyTab Then
KeyAscii = 0
txtedit.SetFocus
End If
But that didn't work either. Any suggestions on how to keep it from tabbing out of the textbox?
------------------
Ryan
-
Feb 9th, 2000, 07:24 AM
#2
Lively Member
Try it in the keydown event or Keyup event
-
Feb 9th, 2000, 07:32 AM
#3
Thread Starter
Hyperactive Member
No, that didn't work. I think it's because in the KeyDown and KeyUp events the KeyAscii doesn't work.
------------------
Ryan
-
Feb 9th, 2000, 07:46 AM
#4
Junior Member
First of all, in the KeyDown and KeyUp command you have Keycode insted of the KeyAscii.
Second, It still won't do what you want it to do... I really don't remember the way to do what you want but you can try setting all the "Tabstop" values to false...
If you don't get a better reply I'll try finding the easier way to do it
-
Feb 9th, 2000, 07:57 AM
#5
Thread Starter
Hyperactive Member
I can't set all the TabStop values to 0 because I still need to be able to tab to the other textboxes, but just not from this textbox.
------------------
Ryan
-
Feb 9th, 2000, 08:46 AM
#6
What The_Inspector suggested is really your only solution, here's an example of how to implement it easily without loosing all Tab Functionality:
Code:
Private Sub Text1_GotFocus()
EnableTabs False
End Sub
Private Sub Text1_LostFocus()
EnableTabs
End Sub
Private Sub EnableTabs(Optional ByVal EnabledThem As Boolean = True)
On Error Resume Next
Dim oControl As Control
For Each oControl In Controls
oControl.TabStop = EnabledThem
Next
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 9th, 2000, 08:56 AM
#7
Thread Starter
Hyperactive Member
ok, yeah, now I see how I can apply what The_Inspector said. Thanks for your help, both of you.
------------------
Ryan
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
|