Click to See Complete Forum and Search --> : Comboboxes


valkyrie
December 9th, 1999, 02:21 AM
Hi again,
Is there anyway for me to set the maximum length of characters which the user may enter(I am using Combobox with Style 0), so that I can prevent an overflow during data entry?

____________________________________
The VB Bugs in my Life...

Chris Eastwood
December 9th, 1999, 02:45 AM
Take a form with a combo (combo1) and paste in the following:


option Explicit

private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (byval hwnd as Long, byval wMsg as Long, byval wParam as Long, byval lParam as Long) as Long
private Const CB_LIMITTEXT = &H141

private Sub Form_Load()
Dim lRet as Long
'
Dim lTextLimit as Long
'
lTextLimit = 4 ' only four characters allowed in combo
'
lRet = SendMessageLong(Combo1.hwnd, CB_LIMITTEXT, lTextLimit, 0)

End Sub





Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

valkyrie
December 9th, 1999, 02:56 AM
Thanks!!

It works!


____________________________________
The VB Bugs in my Life...