新建From1(窗体),新建Text1(TextBox),代码:
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or KeyAscii = Asc(".") Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete) Then
KeyAscii = 0
End If
End Sub
这样就可以输入 127.0.0.1 ,除了退格键和删除键,其它按键无效,Ctrl+V都没法。