Textbox problem

M

mondolfo

Hello there, I`m trying to make a textbox that only accept numbers
including zero (0), I wrote a code, it work fine, but the only problem
is that this code
doesn`t accept zero witch is bad. Can you please send me a code that
accept only numbers?. Thanks.

‘************** Star code

Private Sub TextBox3_Change()

If TextBox3.Value <> "" And Val(TextBox3.Value) = 0 Then

MsgBox "Unicamente se permiten valores numéricos", vbCritical,
"...::: Error :::..."

TextBox3.Value = ""

TextBox3.SetFocus

CommandButton1.Visible = False

CommandButton2.Visible = False

TextBox4.Visible = False

Else

CommandButton1.Visible = True

CommandButton2.Visible = True

TextBox4.Visible = True

End If

If Val(TextBox3.Value) > Val(TextBox2.Value) Then

MsgBox "El número máximo permisible de piezas defectuosas no puede

superar a el de la muestra.", vbCritical, "...::: Error :::..."

TextBox3.Value = ""

TextBox3.SetFocus

TextBox4.Visible = False

End If

End Sub

‘*************** End Code

Thanks for your help I sorry about my English, I`m from Colombia South

America.
 
C

colofnature

Try changing:

If TextBox3.Value <> "" And Val(TextBox3.Value) = 0 Then

To:

If Not IsNumeric(TextBox3.Value) The
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top