Private Sub Textbox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = ValidarCaracter(KeyAscii, TextBox2.Text)
End Sub
Private Sub Textbox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = ValidarCaracter(KeyAscii, TextBox3.Text)
End Sub
Private Sub Textbox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = ValidarCaracter(KeyAscii, TextBox1.Text)
End Sub
Public Function ValidarCaracter(ByVal TeclaPulsada As Integer, txt As String) As Integer
If (TeclaPulsada >= 48 And TeclaPulsada <= 57) Or (TeclaPulsada = 46) Then
ValidarCaracter = TeclaPulsada
Else
ValidarCaracter = 0
End If
If Chr(TeclaPulsada) = "." Then
If InStr(txt, ".") > 0 Or Len(txt) = 0 Then ValidarCaracter = 0
End If
End Function