[OTP] VB6 keypress probs

sup. im doing my computer programming ISU in vb. but im having a wierd problem. it might seem easy to u peaple but i only started learning vb a month ago. i learned how to move stuff with the keypress thing but the game im making the keyypress wont work with it. heres the code

Dim a(0 To 5) As Integer
Dim b As Integer

Private Sub Command1_Click()
a(0) = Rnd() * 40 + 10
a(1) = Rnd() * 40 + 10
a(2) = Rnd() * 40 + 10
a(3) = Rnd() * 40 + 10
a(4) = Rnd() * 40 + 10
a(5) = Rnd() * 40 + 10
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
Label1.Caption = KeyAscii
If KeyAscii = 119 Then
Image1.Top = Image1.Top - 300
Else
If KeyAscii = 115 Then
Image1.Top = Image1.Top + 300
Else
If KeyAscii = 97 Then
Image1.Left = Image1.Left - 300
Else
If KeyAscii = 100 Then
Image1.Left = Image1.Left + 300
End If
If KeyAscii = 114 Then
Image1.Width = Image1.Width + 100
Image1.Height = Image1.Height + 100
End If
If KeyAscii = 102 Then
Image1.Width = Image1.Width - 100
Image1.Height = Image1.Height - 100
End If
End Sub


Private Sub Timer1_Timer()
b = Rnd() * 9720
Image2(0).Top = Image2(0).Top + a(0)
Image2(1).Top = Image2(1).Top + a(1)
Image2(2).Top = Image2(2).Top + a(2)
Image2(3).Top = Image2(3).Top + a(3)
Image2(4).Top = Image2(4).Top + a(4)
Image2(5).Top = Image2(5).Top + a(5)

If Image2(0).Top >= 8880 Then
Image2(0).Top = 0
Image2(0).Left = b
End If
If Image2(1).Top >= 8880 Then
Image2(1).Top = 0
Image2(1).Left = b
End If
If Image2(2).Top >= 8880 Then
Image2(2).Top = 0
Image2(2).Left = b
End If
If Image2(3).Top >= 8880 Then
Image2(3).Top = 0
Image2(3).Left = b
End If
If Image2(4).Top >= 8880 Then
Image2(4).Top = 0
Image2(4).Left = b
End If
If Image2(5).Top >= 8880 Then
Image2(5).Top = 0
Image2(5).Left = b
End If
End Sub

the wierd thing is it doesnt even seem to take in the ascii number becouse i made it so a label would show the number when i pressed a keyboard button but its not changing. it changes when i use the label code on a simpler program but its not working on this one. pls help me



Answer this question

[OTP] VB6 keypress probs