Private Sub Text1_Validate(Cancel As Boolean)
Dim n() As Byte
Dim HayPunto As Boolean
If Text1.Text = "" Then
MsgBox "La caja de texto no puede quedar vacía, escriba al menos un 0."
Cancel = True
Else
n = Text1.Text
For k = 0 To UBound(n) Step 2
If n(k) > 47 Then
If n(k) > 58 Then
MsgBox "No se permiten caracteres, sólo números."
Cancel = True
Exit Sub
End If
Else
If n(k) = 46 Then
If HayPunto = False Then
HayPunto = True
Else
MsgBox "Sólo se permite un punto para el número, como separador decimal."
Cancel = True
Exit Sub
End If
Else
MsgBox "No se permiten caracteres, sólo números."
Cancel = True
Exit Sub
End If
End If
Next
End If
End Sub