Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const EM_LIMITTEXT = &HC5Private Sub Command1_Click()
'限制长度
rc = SendMessage(Text1.hwnd, EM_LIMITTEXT, 5, 0)
End Sub

解决方案 »

  1.   

    这样也行!
    Private Sub Combo1_KeyPress(KeyAscii As Integer)
        If (KeyAscii <> 13) And (KeyAscii <> 8) Then
            If Len(Combo1.Text) >= LenNum Then KeyAscii = 0
        End If
    End SubLenNum 为要限制的长度
      

  2.   

    对不起,是这个:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongConst CB_LIMITTEXT = &H141Private Sub Command1_Click()
    '限制长度
    rs = SendMessage(Combo1.hwnd, CB_LIMITTEXT, 5, 0)
    End Sub
      

  3.   

    谢谢两位!请问dbcontrols(泰山) zgjchina1(还俗和尚.COM) 你们是不是这里专门回答问题的高手,就像以前的吴文智,怎么好久不见他啦