可以把你的combobox的值列表最后加上两项,这两项为一个空格符用来判断,比如可以这样: A B C D E F " " 一个空格符的值 " " 一个空格符的值然后在Combo1_Scroll事件中 If Combo1.List(Combo1.ListIndex) = " " Then Combo1.ListIndex = 0 End If呵呵,想的个笨办法,试试My Email:[email protected]
Option ExplicitPrivate Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer) Combo1.Tag = CStr(Combo1.ListIndex) End SubPrivate Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyDown And Combo1.ListIndex = Val(Combo1.Tag) Then Combo1.ListIndex = 0 ElseIf KeyCode = vbKeyUp And Combo1.ListIndex = Val(Combo1.Tag) Then Combo1.ListIndex = Combo1.ListCount - 1 End If End SubPrivate Sub Form_Load() Combo1.AddItem "A" Combo1.AddItem "B" Combo1.AddItem "C" Combo1.AddItem "D" Combo1.AddItem "E" Combo1.AddItem "F" End Sub
好像不行啊!不过可以跳转到第二个。Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 40 And Combo1.ListIndex = Combo1.ListCount - 1 Then Combo1.Refresh Combo1.ListIndex = 0 End If End Sub
A
B
C
D
E
F
" " 一个空格符的值
" " 一个空格符的值然后在Combo1_Scroll事件中
If Combo1.List(Combo1.ListIndex) = " " Then
Combo1.ListIndex = 0
End If呵呵,想的个笨办法,试试My Email:[email protected]
Combo1.Tag = CStr(Combo1.ListIndex)
End SubPrivate Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown And Combo1.ListIndex = Val(Combo1.Tag) Then
Combo1.ListIndex = 0
ElseIf KeyCode = vbKeyUp And Combo1.ListIndex = Val(Combo1.Tag) Then
Combo1.ListIndex = Combo1.ListCount - 1
End If
End SubPrivate Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"
Combo1.AddItem "C"
Combo1.AddItem "D"
Combo1.AddItem "E"
Combo1.AddItem "F"
End Sub
If KeyCode = 40 And Combo1.ListIndex = Combo1.ListCount - 1 Then
Combo1.Refresh
Combo1.ListIndex = 0
End If
End Sub