02. juni 2003 - 13:00Der er
7 kommentarer og 1 løsning
keypresses som registreres konstant
hejsa jeg er ved at lave en slot-maskine, men jeghar lige et lille problem.
følgende kode gør at man, hvis checkboksen er markeret, kan trykke henholdsvis 1,2 og 3 for at hold på hjulene. ---------- Private Sub Check1_KeyPress(KeyAscii As Integer) If KeyAscii = 49 Then If Check1.Value = 1 Then Check1.Value = 0 Else Check1.Value = 1 End If End If End Sub
Private Sub Check2_KeyPress(KeyAscii As Integer) If KeyAscii = 50 Then If Check2.Value = 1 Then Check2.Value = 0 Else Check2.Value = 1 End If End If End Sub
Private Sub Check3_KeyPress(KeyAscii As Integer) If KeyAscii = 51 Then If Check3.Value = 1 Then Check3.Value = 0 Else Check3.Value = 1 End If End If End Sub ---------------
dette er dog ikke hvad jeg ønsker.. jeg ønsker at man bare kan trykke 1,2 eller 3, ligegyldigt hvor hvilken boks elelr knap man har markeret.. er der nogen der kan hjælpe med dette ??
Public Sub Form_KeyPreview() '-------------------------------- 'This makes the wheels respond to keypresses '-------------------------------- If KeyAscii = 49 Then If Check1.Value = 1 Then Check1.Value = 0 Else Check1.Value = 1 End If End If End Sub
således ? .. det virker desværre ikke ..
ps, jeg bruger det i skolen, og det er mit første større program, så jeg er ik lige den største ørn til programmering 8))
Ja der fik jeg forvirret dig... ;-) Du markerer formen, og bladrer ned til KeyPreview i Properties vinduet. Den står normalt til False. Sæt den til True. Så bruger du f.eks. flg.
Public Sub Form_KeyPress(KeyAscii as integer) '-------------------------------- 'This makes the wheels respond to keypresses '-------------------------------- If KeyAscii = 49 Then If Check1.Value = 1 Then Check1.Value = 0 Else Check1.Value = 1 End If End If End Sub
Public Sub Form_KeyPress() If KeyAscii = 49 Then If Check1.Value = 1 Then Check1.Value = 0 Else Check1.Value = 1 End If End If End Sub ------------- stadig ingen funktion
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.