FIX: ComboBox, Arabic text cannot be retrieved by typing its characters.
The information in this article applies to:
- Visual Basic 6.0
- Windows 2000, Windows XP
SYMPTOMS
When you set the ComboBox properties to:
Sorted: True Style: 2-Dropdown List
At runtime, the ComboBox Arabic items cannot be retrieved just by typing its first
characters.If you change the ComboBox property Style to: 1-Dropdown Combo it will
work fine, but it may not be your requirement.

FIX
You can fix this bug by following these steps:
- Step 1: Declare a public InputStr
'This variable has to be public
Public InputStr As String
'The input string |
- Step 2: Add the ComboFix sub to the first Form declaration area:
'This public function handles Arabic text Selection in a combobox
'it has to be called from any combobox wants to fix such problem
Public Sub ComboFix(Combo As VB.ComboBox, KeyAscii As Integer)
  Dim Str As String ' The combobox items
  InputStr = InputStr + String(1, KeyAscii)
  Dim Result As Integer, Snooze As Boolean
  Snooze = False
  ' Go through the elements and check if they match the input
  For I = 0 To Combo.ListCount - 1
    Str = Combo.List(I)
    ' Check that the input matches the combo item
    If 0 = StrComp(InputStr, Left(Str, Len(InputStr)), vbTextCompare) Then
      Combo.ListIndex = I
      Combo.Text = Str
      Snooze = True ' We have to wait for more input
      Exit For ' Item is found exit the loop
    End If
  Next I
  ' If letter found then
  ' wait for new input before refreshing the buffer
  If Snooze = True Then
    Dim PauseTime, Start
    PauseTime = 3 ' Wait 3 seconds
    Start = Timer
    Do While Timer < Start + PauseTime
      DoEvents ' Accept input
    Loop
  End If
  InputStr = "" ' Reset the input string
End Sub
|
- Step 3: In the Combox_keypressed, add the following code:
'The KeyPress handling sub
'ComboFix has to be called at the very beginning of this sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
  ComboFix (Me.Combo1, KeyAscii) ' Call the function to handle text selections
End Sub |
- Step 4: In the Form_load you have to initialize the InputStr:
Private Sub Form_Load()
  InputStr = "" ' Initialize the input string
|

|