Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combobox
Message
 
À
21/08/2001 04:17:07
Information générale
Forum:
Visual Basic
Catégorie:
Fonctions API de Windows
Titre:
Divers
Thread ID:
00546593
Message ID:
00546639
Vues:
20
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform