• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

combo box mimic max length

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
0
jackjohnson44
Asked:
jackjohnson44
1 Solution
 
EDDYKTCommented:
do this

 If Len(cmbText1.Text) >= 4 Then
        cmbText1.Text = Mid(tmpStr, 1, 3)
    End If
cmbText1.SetFocus
SendKeys "{END}"
0
 
jackjohnson44Author Commented:
thanks
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now