先判断是否为数字和:
在你的判断的基础上加
Private Sub Text_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii > 47 And KeyAscii <= 58  ) Then
    KeyAscii = 0
End If
end sub

解决方案 »

  1.   

    Private Sub Text_KeyPress(KeyAscii As Integer)
    If Not ((KeyAscii > 47 And KeyAscii <= 58  ) Then
        KeyAscii = 0
    End If
    end sub 
    这段代码不好使,我试了
      

  2.   

    用MaskEdit控件,将Mask属性设为“##:##“,Promptchar设为空格即可,但是你的程序里要判断一下用户输入的数字是不是符合时间规则,即小时不能超过24,分钟不能超过60。
      

  3.   

    用MaskEdit控件 customformat="hh:mm"
      

  4.   

    用 DTPicker 也行
    选部件,再Microsoft Windows Common Controls-2 6.0(SP3)DTPicker1.Format = dtpCustom
    DTPicker1.CustomFormat = "hh:mm"
      

  5.   

    DTPicker1.Value = Time
    DTPicker1.Format = dtpCustom
    DTPicker1.CustomFormat = "hh:mm"