خواهید دید که بغییر از عدد چیز دیگری تایپ نمیشود
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii > Asc("9") Or KeyAscii < Asc("0") Then
If KeyAscii = Asc("-") Then
If InStr(1, Me.TextBox1.Text, "-") > 0 Or _
Me.TextBox1.SelStart > 0 Then KeyAscii = 0
ElseIf KeyAscii = Asc(".") Then
If InStr(1, Me.TextBox1.Text, ".") > 0 Then KeyAscii = 0
Else
KeyAscii = 0
End If
End If
End Sub




کامنت