Attribute VB_Name = "Module1"
Dim kas As KeyCodeConstants
Dim c As ComboBox
Dim ary()
Dim Ptext As String
Dim Slen As Integer
Dim Sst As Integer
Dim zx As Integer
Dim Tx As String
Dim ind As Integer
Dim cnt As Control
Public z
Public IsFound As Boolean

Public Sub com6(c, kas, cnt)
    If c.SelLength = Len(c.Text) And kas <> 13 Then c.Text = ""
    IsFound = False
    ''Ind = -1
    ReDim ary(c.ListCount)
    zx = c.ListCount
    For j = 0 To c.ListCount - 1
    ary(j) = c.List(j)
    Next

    Select Case kas
        Case 32, 48 To 57, 65 To 90, 97 To 122
        If c.Text = "" Then
            Tx = ""
            Ptext = ""
        Else
            Ptext = c.Text
            Slen = c.SelLength
            Sst = c.SelStart
        End If
        Tx = Tx + Chr(kas)
        For i = 0 To c.ListCount
        XX = Left(c.List(i), Len(Tx))
        yy = Tx
        If UCase(XX) = UCase(yy) Then
            ind = i
            IsFound = True
            Tx2 = c.List(i)
            c.Text = Tx2
            c.SelStart = Len(Tx)
            c.SelLength = Len(Tx2) - Len(Tx)
            kas = 0
            Exit For
        Else
            IsFound = False
        End If
        Next
        If IsFound = False Then
            c.Clear
            kas = 0
            Tx = Left(Tx, Len(Tx) - 1)
            XX = Tx
            c.Text = Ptext
            c.SelStart = Sst
            c.SelLength = Slen
            For k = 0 To zx - 1
            c.AddItem (ary(k))
            Next
        End If
        Case 8
        On Error GoTo 999
        If c.SelLength > 0 Then
            Tx = Left(c.Text, Len(c.Text) - c.SelLength)
        Else
            Tx = Left(c.Text, Len(c.Text) - 1)
        End If
        If Len(c.Text) = 1 Then Ptext = ""
        Case 13
        If Len(c.Text) > 0 Then
            vv = c.List(ind)
            If IsFound = True Then
                c.Text = c.List(ind)
            End If
            Ptext = ""
            cnt.SetFocus
        End If
        Exit Sub
999     If Err.Number = 5 Then
            '''ok
        End If
        Case 38, 40
        Exit Sub
        Case Else
        kas = 0
    End Select
End Sub

Public Sub com66(c, kas, cnt)
    If c.SelLength = Len(c.Text) And kas <> 13 Then c.Text = ""

    IsFound = False
    ReDim ary(c.ListCount)
    zx = c.ListCount
    For j = 0 To c.ListCount - 1
    ary(j) = c.List(j)
    Next

    Select Case kas
        Case 32, 48 To 57, 65 To 90, 97 To 122
        If c.Text = "" Then
            Tx = ""
            Ptext = ""
        Else
            Ptext = c.Text
            Slen = c.SelLength
            Sst = c.SelStart
        End If
        Tx = Tx + Chr(kas)
        For i = 0 To c.ListCount
        XX = Left(c.List(i), Len(Tx))
        yy = Tx
        If UCase(XX) = UCase(yy) Then
            ind = i
            IsFound = True
            Tx2 = c.List(i)
            c.Text = Tx2
            c.SelStart = Len(Tx)
            c.SelLength = Len(Tx2) - Len(Tx)
            kas = 0
            Exit For
        Else
            IsFound = False
        End If
        Next
        Case 8
        On Error GoTo 999
        If c.SelLength > 0 Then
            Tx = Left(c.Text, Len(c.Text) - c.SelLength)
        Else
            Tx = Left(c.Text, Len(c.Text) - 1)
        End If
        If Len(c.Text) = 1 Then Ptext = ""
        Case 13
        If Len(c.Text) > 0 Then
            vv = c.List(ind)
            If IsFound = True Then
                c.Text = c.List(ind)
            Else
                If c.SelLength <> Len(c.Text) Then c.AddItem c.Text
            End If
            Ptext = ""
            ZZ = c.Text
            c.ListIndex = 0
            c.Text = ZZ
            cnt.SetFocus
        End If
        Exit Sub
999     If Err.Number = 5 Then
        End If
        Case Else
    End Select
End Sub

Public Sub SetCase(Ks As Integer, Cont As Control)
    If Chr(Ks) >= "a" And Chr(Ks) <= "z" And (Right(Cont.Text, 1) = "." Or Right(Cont.Text, 1) = " " Or Len(Cont.Text) = 0 Or Cont.SelLength = Len(Cont.Text)) Then
        Ks = Ks - 32
    End If
End Sub

