Advertisement
Java_Volume1 Miscellaneous #90843

AutoComplete

Add the Internet Explorer 4 AutoComplete effect to a common combo box

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Private Sub Form_Load()
  Combo1.AddItem "Computer"
  Combo1.AddItem "Screen"
  Combo1.AddItem "Screen saver"
  Combo1.AddItem "Printer"
  Combo1.AddItem "Printer cartridge"
  Combo1.AddItem "Printer cable"
  Combo1.AddItem "Modem"
  Combo1.AddItem "Speakers"
  Combo1.AddItem "Keyboard"
  Combo1.AddItem "Mouse"
  Combo1.AddItem "Floppy disks"
  Combo1.AddItem "Floppy disk drive"
  Combo1.AddItem "Compact disk"
  Combo1.AddItem "Hard drive"
  Combo1.AddItem "Hardware"
  Combo1.AddItem "Software"
  Combo1.AddItem "Motherboard"
  Combo1.AddItem "Sound card"
  Combo1.AddItem "Webcam"
  Combo1.AddItem "Joystick"
  Combo1.AddItem "Mouse pad"
  Combo1.AddItem "Laser printer"
  Combo1.AddItem "Network card"
  Combo1.AddItem "ISDN card"
  Combo1.AddItem "HUB"
  
  Combo1.Text = ""
  AutoInput = False
  
End Sub

Private Sub Combo1_Change()
  Dim i As Integer
  If Combo1.Text <> "" And AutoInput = False Then
    RealLen = Len(Combo1.Text)
    Do
      If LCase(Combo1.Text) = LCase(Combo1.List(i)) Then
        Exit Sub
      ElseIf LCase(Combo1.Text) = LCase(Left(Combo1.List(i), RealLen)) Then
        AutoInput = True
        Combo1.Text = Combo1.List(i)
        Combo1.SelStart = RealLen
        Combo1.SelLength = Len(Combo1.Text) - RealLen
      End If
    i = i + 1
    Loop Until i = Combo1.ListCount
  Else
    AutoInput = False
  End If
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
  If KeyCode = 8 Then
    If RealLen > 0 And Combo1.SelLength > 0 Then
      Combo1.SelStart = RealLen - 1
      Combo1.SelLength = Len(Combo1.Text) - RealLen + 1
    End If
  ElseIf KeyCode = 46 Then
    If Combo1.SelLength <> 0 Then
      Combo1.Text = Left(Combo1.Text, RealLen)
      AutoInput = True
    End If
  End If
End Sub
Original Comments (3)
Recovered from Wayback Machine