PDA

View Full Version : tab inside of text box? or just a "bug" ?



wolf.stalker
02-22-2008, 05:02 AM
hi all.

I have a unique "bug" i think. i have created a form in excel that has multi text boxes in it. in each of these text boxes, i have a check to ensure that they only key in 0-9. it looks kinda like this

Gross * Net
|--txtbox--| |--txtbox--| prod 1
.
.
.
|--txtbox--| |--txtbox--| prod 5

they way it is suppose to work, is they key in a value for gross prod (1). it will then allow them to key in a value for net prod (1) and if they hit tab it will tab TO net prod (2) box. if they do not enter a value in gross prod (1), a tab will go to gross prod (2) all the way through five.

a user stated that when they key in a value for gross/net prod (1), they tab and it goes to gross(2) {which is correct}. they key in a value for gross prod (2) and when they hit the tab key, it TABS inside that box (like a tab indent).

i ran the orginal .xls from my end, followed what they did and got the same result. i opened up the debugger, walked through all the events related, saw no problems. closed out the debuggger window and it worked fine till prod (5). repeated same process again with debugger and again changed NOTHING. i exited excel, opened file and ran app with NO issues this time!

any ideas on what might be the "issue" if any???

Bob Phillips
02-22-2008, 05:59 AM
Can you post your code, I am not seeing it.

wolf.stalker
02-22-2008, 06:15 AM
Can you post your code, I am not seeing it.

sure here is a set of code for one of the boxes. they are all pretty much the same. does this help?




'******************************************************

Private Sub txtGross1_Exit(ByVal Cancel As MSForms.ReturnBoolean)


If txtGross1.Value = 0 Then
MsgBox ("You must key in some value other than multiple zeros")
txtGross1.Text = ""
txtNet1.Enabled = False
txtGross1.SetFocus
Exit Sub

End If

End Sub

'******************************************************

Private Sub txtGross1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

' just checks to make sure user keys in proper values.


Select Case KeyAscii


Case 48 To 57 ' for number 0-9
txtUnl1.Enabled = True

Case Else
MsgBox "Only numericals are allowed"
KeyAscii = 0

End Select

End Sub

'******************************************************

tstav
02-24-2008, 07:27 AM
any ideas on what might be the "issue" if any???
Quoted by:wolf.stalker
I came across the same issue some weeks ago. After writing something in a textbox, tabbing would not take me to the next textbox in the Form, but rather it would tab inside the same text box.
The catch is that this only happend on PCs running on Windows NT 4.0. When the same code ran on PCs with Win2000 or WinXP, tabbing worked as expected (jumped from text box to textbox).
I didn't try to find a solution to this, since we scarcely use the WinNT PCs.
I'm just telling you what caught my attention, just in case...

tstav
02-24-2008, 08:22 AM
wolf.stalker, check this code to see if it suits your needs.
I have substituted your _keypress and _exit events with only the following _keyDown event.

Private Sub txtGross1_KeyDown _
(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Select Case KeyCode
'Allow only digits and Del,Left,Right,Backspace,Home,End keystrokes
Case vbKey0, vbKey1, vbKey2, vbKey3, vbKey4, vbKey5, vbKey6, vbKey7, vbKey8, vbKey9, _
vbKeyNumpad0, vbKeyNumpad1, vbKeyNumpad2, vbKeyNumpad3, vbKeyNumpad4, _
vbKeyNumpad5, vbKeyNumpad6, vbKeyNumpad7, vbKeyNumpad8, vbKeyNumpad9, _
vbKeyDelete, vbKeyLeft, vbKeyRight, vbKeyBack, vbKeyHome, vbKeyEnd
'If tab, act accordingly
Case vbKeyTab
KeyCode = 0
If txtGross1.Value = 0 Then
MsgBox ("You must key in some value other than multiple zeros")
txtGross1.Text = ""
txtGross1.SetFocus
ElseIf txtGross1.Value = "" Then
txtGross2.SetFocus
End If
'Else alert the user
Case Else
KeyCode = 0
Beep
End Select
End Sub

wolf.stalker
02-24-2008, 09:15 AM
hmm, i can try that which i have no problem doing...but my question still remains...is my problem a bug or what?

mikerickson
02-24-2008, 01:17 PM
It sounds like the .TabKeyBehaviour property of the TextBox is set to True.

tstav
02-24-2008, 01:28 PM
Yes mikerickson, it does sound a lot like the .TabKeyBehavior property.
Still, I'm pretty much sure that even though the property was set to false, it acted as if it was set to true, ONLY on a WinNT machine.
I may be able to retest it tomorrow. If I do, I'll get back to you.

wolf.stalker
02-24-2008, 02:36 PM
I came across the same issue some weeks ago. After writing something in a textbox, tabbing would not take me to the next textbox in the Form, but rather it would tab inside the same text box.
The catch is that this only happend on PCs running on Windows NT 4.0. When the same code ran on PCs with Win2000 or WinXP, tabbing worked as expected (jumped from text box to textbox).
I didn't try to find a solution to this, since we scarcely use the WinNT PCs.
I'm just telling you what caught my attention, just in case...

tstav:

sorry, i missed this post but saw the one for the code. it sounds like this is just an odd behavior for NT?.

tstav
02-25-2008, 04:19 PM
wolf.stalker:it sounds like this is just an odd behavior for NT?
Like I said, I will try to re-test this on a WinNT PC I have in my office, but I will not be there until next week.