VB 6.0 - WordWheel required

Posted on 2000-01-24
Medium Priority
Last Modified: 2010-05-02
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 ...

Question by:jarrod100
  • 2
LVL 32

Accepted Solution

Erick37 earned 400 total points
ID: 2383344
"HOWTO: Search a ListBox Control Quickly"


Expert Comment

ID: 2383356

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
If cntr1 < Dictionary.ListCount - 1 Then
   cntr1 = cntr1 + 1
End If
End If
Next cntr1

End Sub

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

Hope this helps,

Author Comment

ID: 2383389
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

LVL 32

Expert Comment

ID: 2383424
Glad to help.  Thanks.

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question