Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)If KeyAscii > 47 And KeyAscii < 58 Then Exit Sub '允许输入0-9If KeyAscii = 8 Then Exit Sub '允许退格If KeyAscii = 46 Then Exit Sub '允许tab'同理可添加允许的其它键值'其它键值都不允许KeyAscii = 0End Sub