combo box mimic max length

Posted on 2006-05-08
Last Modified: 2010-08-05
I have a combo box that I want to have a max lenght.
I found a way to do it with the code below.
I want the cursor to be at the end of the text after exiting the funciton.

This will put the cursor to before the first character.
If I add         cmbText1.SetFocus at the end, it will highlight the text.
I just want the cursor to be at the end.

Private Sub cmbText1_Change()
    Dim tmpStr$
    tmpStr = cmbText1.Text
    Debug.Print Mid(tmpStr, 1, 3)
    If Len(cmbText1.Text) >= 4 Then
        cmbText1.Text = Mid(tmpStr, 1, 3)
    End If
Question by:jackjohnson44
    LVL 26

    Accepted Solution

    do this

     If Len(cmbText1.Text) >= 4 Then
            cmbText1.Text = Mid(tmpStr, 1, 3)
        End If
    SendKeys "{END}"

    Author Comment


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now