+ Reply to Thread
Results 1 to 3 of 3

Textbox problem

  1. #1
    Registered User
    Join Date
    12-02-2004
    Posts
    2

    Textbox problem

    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.

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Try changing:

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

    To:

    If Not IsNumeric(TextBox3.Value) Then

  3. #3
    K Dales
    Guest

    RE: Textbox problem

    If Not(IsNumeric(TextBox3.Value)) Then...
    --
    - K Dales


    "mondolfo" wrote:

    >
    > 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.
    >
    >
    > --
    > mondolfo
    > ------------------------------------------------------------------------
    > mondolfo's Profile: http://www.excelforum.com/member.php...o&userid=17083
    > View this thread: http://www.excelforum.com/showthread...hreadid=544781
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1