Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox
Message
 
To
21/08/2001 04:17:07
General information
Forum:
Visual Basic
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00546593
Message ID:
00546639
Views:
17
>What is the way to limit the user from entering predefined number of characters in a combobox.
>
>I tried using API SENDMESSAGE with a constatnt CB_LIMITTEXT, but unfortunately it did not work
>
>Any Ideas?

Is your code looks like this:
Option Explicit

Private Declare Function SendMessage Lib "user32" _
    Alias "SendMessageA" (ByVal hwnd As Long, _
    ByVal wMsg As Long, ByVal wParam As Long, _
    lParam As Any) As Long

Private Const CB_LIMITTEXT = &H141

Public Sub LimitCBText(CB As ComboBox, _
   MaxLength As Long)
    
    'usage: CB = ComboBox to limit length of
    'MaxLength: Max characters allowed
    'Example: LimitCBText Combo1, 5
    
    SendMessage CB.hwnd, CB_LIMITTEXT, MaxLength, 0&
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform