cool_dude
08-05-2005, 07:10 PM
hello
im trying to make a smart combo box that will loop through itself when KeyPress is activated and set the number that is pressed.
i have a combo box with years loaded in it ranging from 1930 to 2005. when the user will press 1 it will automaticly go to the first number starting with one wich is 1999, then if the user will press 8 it will go to 1899 and so on.
just for the info.......my combo box style is set to "2 - Dropdown List"
i have tried doing this myself but i dont see where im going with this :confused:, so maybe you can help me.
this is where im stuck
Private Sub cboYr_KeyPress(KeyAscii As Integer)
Dim i As Integer
Dim srch As Byte
If KeyAscii >= 48 And KeyAscii <= 57 Then
For i = 0 To cboYr.ListCount - 1
If KeyAscii = cboYr.List(i) Then cboYr.Text = cboYr.List(i)
Next i
For srch = 1 To 5
For i = 0 To cboYr.ListCount - 1
If cboYr.List(i) = KeyAscii Then
cboYr.SelStart (srch - 1)
End If
Next i
Next i
End If
End Sub
thanks for your time!
im trying to make a smart combo box that will loop through itself when KeyPress is activated and set the number that is pressed.
i have a combo box with years loaded in it ranging from 1930 to 2005. when the user will press 1 it will automaticly go to the first number starting with one wich is 1999, then if the user will press 8 it will go to 1899 and so on.
just for the info.......my combo box style is set to "2 - Dropdown List"
i have tried doing this myself but i dont see where im going with this :confused:, so maybe you can help me.
this is where im stuck
Private Sub cboYr_KeyPress(KeyAscii As Integer)
Dim i As Integer
Dim srch As Byte
If KeyAscii >= 48 And KeyAscii <= 57 Then
For i = 0 To cboYr.ListCount - 1
If KeyAscii = cboYr.List(i) Then cboYr.Text = cboYr.List(i)
Next i
For srch = 1 To 5
For i = 0 To cboYr.ListCount - 1
If cboYr.List(i) = KeyAscii Then
cboYr.SelStart (srch - 1)
End If
Next i
Next i
End If
End Sub
thanks for your time!