Solved

drop-down combo box

Posted on 1998-08-30
4
242 Views
Last Modified: 2012-05-04
How can I add a typomatic feature to a drop-down combo box?
0
Comment
Question by:gcassel
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1431936
What does typomatic mean?
0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1431937
gcassel,
Try this code. Let me know if this is not what you want.
Regards
Dalin

'In the form's General Declaration area, add:
Declare Function SendMessage Lib "User32" Alias _
  "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
  ByVal wParam As Long, lParam As Any) As Long

Const CB_ERR = -1
Const CB_FINDSTRING = &H14C

'Add the sub

Sub sMatchEntry(cbo As ComboBox, KeyAscii As Integer)
  Dim sBuffer As String
  Dim lRetVal As Long

  sBuffer = Left(cbo.Text, cbo.SelStart) & Chr(KeyAscii)
  lRetVal = SendMessage((cbo.hWnd), CB_FINDSTRING, _
  -1, ByVal sBuffer)
  If lRetVal <> CB_ERR Then
    With cbo
      .ListIndex = lRetVal
      .Text = .List(lRetVal)
      .SelStart = Len(sBuffer)
      .SelLength = Len(.Text)
    End With
    KeyAscii = 0
  End If
End Sub

' in the KeyPress Event add:

Private Sub Combo1_KeyPress(KeyAscii As Integer)
  sMatchEntry Combo1, KeyAscii
End Sub
0
 

Author Comment

by:gcassel
ID: 1431938
Dalin,
   Thanks. I tried the code but no matter what letter I type I get no response.  I can still though select by clicking on the down arrow and selecting from the drop-down combo box list.  I  however want to be able to use the typomatic feature since my list is rather large.  Any other suggestions on what I might be doing wrong.
Thanks,
Gary
0
 

Author Comment

by:gcassel
ID: 1431939
Dalin,
In looking at the code further each time I enter a key SendMessage returns -1
lRetVal=SendMessage((cbo.hwnd),CB_FINDSTRING, -1, ByVal sBuffer)
  -1                  740          332                     "k"


0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now