Solved

This is for Dalin - re VB Q.10052471 on 5/12/98

Posted on 1998-07-28
3
157 Views
Last Modified: 2010-05-18
Dalin,

Back in May (5/12/98) you offered to email an Experts-Exchange user some code for an "Enhanced Combo Box" (re VB Q.10052471).

I need to use something similar... have a combo box jump to the most appropriate item in the list as I type, and was hoping you would be able to email the code for the combo box to me as well.

I'd be very appreciative.  Please let me know.

-- Stacey --

email:  s033slb@discover.wright.edu


0
Comment
Question by:s033slb
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Dalin earned 10 total points
ID: 1467024
s033sld,
Look for your e-mail
Regards
Dalin
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1467025
I got a returned e-mail.

here is the code:
'Declare
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:s033slb
ID: 1467026
Thanks Dalin,

I'll give a try tomorrow at work.

-- Stacey --

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

20 Experts available now in Live!

Get 1:1 Help Now