RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Feb 21, 2002



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Limit Users Typing in Combo Box

The standard textbox has a MaxChars property that lets you limit the number of characters a user can type into it. The drop-down combo does not, but you can emulate this property setting with a simple API call:
Private Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" (ByVal hWnd _
As Long, ByVal msg As Long, ByVal wParam _
As Long, ByVal lParam As Long) As Long
Private Const CB_LIMITTEXT = &H141
Private Sub Form_Load()
Const Max_Char = 24
Call SendMessage(Combo1.hWnd, _
CB_LIMITTEXT, Max_Char, 0&)
End Sub

This tip works in 16-bit versions of VB as well, but you
Jim Deutch
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date