Numbers Only

How would I make A textBox isert Number only. My Code where the Folowing
If KeyAscii - 8 or KeyAscii =32 then Exit sub
If KeyAscii < 48 or KeyAscii > 57 then
KeyAscii = 0
End If
End sub
I was also useing Visual Basic 6.0!!!!!! Thank you


Comments

  • : How would I make A textBox isert Number only. My Code where the Folowing
    : If KeyAscii - 8 or KeyAscii =32 then Exit sub
    : If KeyAscii < 48 or KeyAscii > 57 then
    : KeyAscii = 0
    : End If
    : End sub
    : I was also useing Visual Basic 6.0!!!!!! Thank you
    :
    :
    :
    If the textbox is named Text1 then the code will look like this...

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    :: If KeyAscii < 48 Or KeyAscii > 57 Then
    :::: If KeyAscii <> 8 or KeyAscii <> 32 then
    :::::: KeyAscii = 0
    :::: End If
    :: End If
    End Sub

    This is pretty much exactly what you have, what isn't working? Do you have it in the KeyPress Event for the TextBox?

    -ray

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion