CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Comboboxes

  1. #1
    Join Date
    Dec 1999
    Location
    Malaysia
    Posts
    56

    Comboboxes

    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...

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Comboboxes

    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

  3. #3
    Join Date
    Dec 1999
    Location
    Malaysia
    Posts
    56

    Re: Comboboxes

    Thanks!!

    It works!


    ____________________________________
    The VB Bugs in my Life...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured