• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

combobox veranderd bij KeyUp 38 en KeyDown 40

Status
Niet open voor verdere reacties.

markwat

Gebruiker
Lid geworden
11 mrt 2011
Berichten
301
De comboboxen vul ik en vervolgens op enter, dat gaat goed.
Wanneer ik de pijltjes gebruikt verspringt de tekst vanuit de combox die ik verlaat.



Code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox2.Activate
End Sub
Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox91.Activate
End Sub

Private Sub ComboBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox3.Activate
End Sub
Private Sub ComboBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox1.Activate
End Sub

Private Sub ComboBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox4.Activate
End Sub
Private Sub ComboBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox2.Activate
End Sub

Private Sub ComboBox4_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox5.Activate
End Sub
Private Sub ComboBox4_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox3.Activate
End Sub

Private Sub ComboBox5_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox6.Activate
End Sub
Private Sub ComboBox5_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox4.Activate
End Sub

Private Sub ComboBox6_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox7.Activate
End Sub
Private Sub ComboBox6_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox5.Activate
End Sub

Private Sub ComboBox7_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox8.Activate
End Sub
Private Sub ComboBox7_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox6.Activate
End Sub

Private Sub ComboBox8_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox9.Activate
End Sub
Private Sub ComboBox8_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox7.Activate
End Sub

Private Sub ComboBox9_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox10.Activate
End Sub
Private Sub ComboBox9_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox8.Activate
End Sub

Private Sub ComboBox10_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox11.Activate
End Sub
Private Sub ComboBox10_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox9.Activate
End Sub

Private Sub ComboBox11_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox12.Activate
End Sub
Private Sub ComboBox11_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox10.Activate
End Sub

Private Sub ComboBox12_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox13.Activate
End Sub
Private Sub ComboBox12_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox11.Activate
End Sub

Private Sub ComboBox13_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox14.Activate
End Sub
Private Sub ComboBox13_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox12.Activate
End Sub

Private Sub ComboBox14_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox15.Activate
End Sub
Private Sub ComboBox14_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox13.Activate
End Sub

Private Sub ComboBox15_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox16.Activate
End Sub
Private Sub ComboBox15_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox14.Activate
End Sub

Private Sub ComboBox16_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox17.Activate
End Sub
Private Sub ComboBox16_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox15.Activate
End Sub

Private Sub ComboBox17_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox18.Activate
End Sub
Private Sub ComboBox17_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox16.Activate
End Sub

Private Sub ComboBox18_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox19.Activate
End Sub
Private Sub ComboBox18_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox17.Activate
End Sub

Private Sub ComboBox19_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox20.Activate
End Sub
Private Sub ComboBox19_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox18.Activate
End Sub

Private Sub ComboBox20_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox21.Activate
End Sub
Private Sub ComboBox20_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox19.Activate
End Sub

Private Sub ComboBox21_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox22.Activate
End Sub
Private Sub ComboBox21_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox20.Activate
End Sub

Private Sub ComboBox22_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox23.Activate
End Sub
Private Sub ComboBox22_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox21.Activate
End Sub

Private Sub ComboBox23_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox24.Activate
End Sub
Private Sub ComboBox23_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox22.Activate
End Sub

Private Sub ComboBox24_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox25.Activate
End Sub
Private Sub ComboBox24_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox23.Activate
End Sub

Private Sub ComboBox25_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox26.Activate
End Sub
Private Sub ComboBox25_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox24.Activate
End Sub

Private Sub ComboBox26_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox27.Activate
End Sub
Private Sub ComboBox26_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox25.Activate
End Sub

Private Sub ComboBox27_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox28.Activate
End Sub
Private Sub ComboBox27_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox26.Activate
End Sub

Private Sub ComboBox28_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox29.Activate
End Sub
Private Sub ComboBox28_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 38 Then ComboBox27.Activate
End Sub

Private Sub ComboBox29_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 40 Or KeyCode = 13 Then ComboBox30.Activate
End Sub
 
Met een klein anoniem voorbeeldbestandje wordt je sneller en beter geholpen.
 
Doe dit bij al die Keydown gebeurtenissen:
Code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 40 Or KeyCode = 13 Then
        ComboBox2.Activate
        [COLOR="#FF0000"]KeyCode = 0[/COLOR]
    End If
End Sub
 
Laatst bewerkt:
Beste Edmoor,

Bedankt voor de reactie.
Als ik het erbij zet krijg ik; End if zonder blok if.
haal ik End if weg dan kan ik met backspace niet meer de combobox leeg maken.
ook wanneer ik de eerste letter type van een voor geprogrameerde tekst herkend hij niet meer met de aanvulling.
 
Dan heb je het niet gedaan zoals ik liet zien.
 
Beste Edmoor,

klopt ik had het niet correct gezet.
het werkt goed bij down
maar KeyUp kan niet aangepast worden?

groeten paul
 
Bij KeyUp kan je hetzelfde doen.
 
Ik heb het zo gedaan, zie ik iets over het hoofd?

alleen down werkt goed Up blijf nog steeds de tekst veranderen.

Code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 40 Or KeyCode = 13 Then
        ComboBox2.Activate
        KeyCode = 0
    End If
End Sub
Private Sub ComboBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 38 Then
        ComboBox91.Activate
        KeyCode = 0
    End If
End Sub

Private Sub ComboBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 40 Or KeyCode = 13 Then
        ComboBox3.Activate
        KeyCode = 0
    End If
End Sub
Private Sub ComboBox2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 38 Then
        ComboBox1.Activate
        KeyCode = 0
    End If
End Sub

Private Sub ComboBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 40 Or KeyCode = 13 Then
        ComboBox4.Activate
        KeyCode = 0
    End If
End Sub
Private Sub ComboBox3_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = 38 Then
    ComboBox2.Activate
        KeyCode = 0
    End If
End Sub
 
Dan zal de KeyCode niet 38 zijn.
 
En dat heb je in debug mode gecontroleerd?
Plaats anders, zoals al eerder vermeld, een voorbeeld documentje.

Of doe dit in de KeyDown:
Code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    Select Case KeyCode
        Case 38:	ComboBox91.Activate:    KeyCode = 0
        Case 40, 13:	ComboBox2.Activate:	KeyCode = 0
    End Select
End Sub

Dan kan je de KeyUp routines weg laten.
 
Laatst bewerkt:
Lees de aangepaste #11
 
En dat heb je in debug mode gecontroleerd?
Plaats anders, zoals al eerder vermeld, een voorbeeld documentje.

Of doe dit in de KeyDown:
Code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    Select Case KeyCode
        Case 38:	ComboBox91.Activate:    KeyCode = 0
        Case 40, 13:	ComboBox2.Activate:	KeyCode = 0
    End Select
End Sub

Dan kan je de KeyUp routines weg laten.

Beste Edmoor,

Heel hartelijk dank!
Deze Code werkt correct!

Groeten paul m
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan