Link to home
Start Free TrialLog in
Avatar of jarrod100
jarrod100

asked on

VB 6.0 - WordWheel required

Hello there,

could anyone help me with some VB 6 code
for a wordwheel. eg. I need to be able to check for names in a list, where the highlight will jump to the first matching name in alphabetical order ...

10x
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of runner75
runner75

Jarrod100,

for this example create a form:
- and add 1 TextBox (named: s_box) ... search box
- and add 1 ListBox  (named: Dictionary) ... where all your names will reside (populate this from a DB)

in your code : General/Declarations paste the following code:

========> cut here <==============

Private Sub s_box_KeyUp(KeyCode As Integer, Shift As Integer)

Dim cntr1 As Integer 'counter 1
Dim cntr2 As Integer 'counter 2
Dim n_str As String 'new string

' perform the search
n_str = s_box.Text
For cntr1 = 0 To Dictionary.ListCount - 1)
If Len(n_str) <= Len(Dictionary.List(cntr1)) Then
If UCase(Left(n_str, Len(n_str))) = _
            UCase(Left(Dictionary.List(cntr1), Len(n_str))) And _
Len(n_str) <> 0 Then
  Dictionary.Selected(cntr1) = True
  cntr1 = Dictionary.ListCount - 1
End If
Else
If cntr1 < Dictionary.ListCount - 1 Then
   cntr1 = cntr1 + 1
End If
End If
Next cntr1

End Sub

========> cut here <==============

Hope this helps,
runner75
Avatar of jarrod100

ASKER

10x guys,

   both codes seem to work fine:
    - Erick37s' code is shorter :)
    - runner75's code helps me
      understand how the search
      is accomplished.

   you both deserve 100 points,
   however this time Erick37 was
   first :)

10x Erick37

   
Glad to help.  Thanks.