hi!
can someone help me how to convert this code to public function... this code works but the problem is i have to copy it in every combo box command. here's the code
VB Code:
Option Explicit Dim InChangeMode As Boolean Dim BackSpacePressed As Boolean Private Sub Combo1_Change() On Error Resume Next Dim idx As Integer Dim SelFrom As Integer If InChangeMode Then Exit Sub If BackSpacePressed Then BackSpacePressed = False Exit Sub End If With Combo1 If Trim(.Text) = "" Then Exit Sub If .ListCount < 0 Then Exit Sub InChangeMode = True For idx = 0 To .ListCount If UCase(.Text) = UCase(Left(.list(idx), Len(.Text))) Then Exit For '' If your data in Combox is sorted than add the next line ' If UCase(.Text) < UCase(Left(.List(idx), Len(.Text))) Then GoTo EndOfProcess Next idx If idx < .ListCount Then SelFrom = Len(.Text) .ListIndex = idx .SelStart = SelFrom .SelLength = Len(.Text) - SelFrom End If End With EndOfProcess: InChangeMode = False End Sub Private Sub Combo1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case vbKeyBack BackSpacePressed = True End Select End Sub Private Sub Form_Load() 'Dim idx 'With Combo1 '.Clear 'For idx = 65 To 88 '.AddItem Chr(idx) & Chr(idx + 1) & Chr(idx + 2) & "test" 'Next idx 'End With InChangeMode = False BackSpacePressed = False End Sub
thanx for the help!




Reply With Quote