-
October 5th, 2003, 02:39 AM
#1
URGENT!!pls Help Me!!
Last edited by kogan31; October 6th, 2003 at 07:33 AM.
-
October 6th, 2003, 02:54 AM
#2
My KeyDown Event looks like this
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
End Sub
I guess you must be using another type of VB system.
Could it perhaps be VB.NET?
HOWEVER ......
Your problem is that your DIM statement for the iInput value is INSIDE the keydown event (therefore resetting the value to ZERO each time a key is pressed)
something like the following may come close to what you want (VB6 code used)
Private iInput As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 84 Then 'T UpKey
If iInput = 9 Then
iInput = 0 'Reset when at 9
Label2.Caption = iInput
ElseIf iInput < 9 Then
iInput = iInput + 1
Label2.Caption = iInput
End If
ElseIf KeyCode = 68 Then 'D DownKey
If iInput = 0 Then 'Do Not allow any more DownKey presses
Label2.Caption = iInput
ElseIf iInput >= 1 Then
iInput = iInput - 1
Label2.Caption = iInput
End If
End If
End Sub
-
October 6th, 2003, 03:29 AM
#3
hi
thanks for the reply..
but i still cant figure out wats wrong..
when i press the T button the number only increases to 1 and not until 9.
any idea?
pls help
i'm using visual studio.net 2002
-
October 6th, 2003, 12:29 PM
#4
As I said
Your problem is that your DIM statement for the iInput value is INSIDE the keydown event (therefore resetting the value to ZERO each time a key is pressed)
So if you add 1 to Zero each time, you will always only get a result of 1
Define your iInput value OUTSIDE the key_down event eg, in a module or above the event (Right up at the top of the form code)
ie, OUTSIDE the key_down event
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
|