vb.net basic

Discussion in 'OT Technology' started by TD23, Jan 22, 2004.

  1. TD23

    TD23 Bring it home!

    Joined:
    May 6, 2001
    Messages:
    258
    Likes Received:
    0
    Location:
    under your bed
    I cant figure out how to make my inputbox (error check) come up if a NON DECIMAL number is entered. Anyone help me really quick?


    rate = Val(Me.RateTextBox.Text)

    If rate <= 0 Then
    rate = Val(InputBox("Enter a Decimal number.", "What is rate?"))
    Me.RateTextBox.Text = rate
    End If
     
  2. TD23

    TD23 Bring it home!

    Joined:
    May 6, 2001
    Messages:
    258
    Likes Received:
    0
    Location:
    under your bed
    :doh: Sucks to be a newb at teh VB

    rate = Val(Me.RateTextBox.Text)
    If rate <= 0 Then
    rate = Val(InputBox("Enter a positive ber.", "What is rate?"))
    Me.RateTextBox.Text = rate
    End If
    If rate > 1 Then
    rate = rate / 100
    End If
     
  3. DFWSR4EVER

    DFWSR4EVER There's Stlil Time to Change the Road You're On

    Joined:
    Jul 29, 2001
    Messages:
    51,573
    Likes Received:
    0
    Location:
    Wisco
    it's called computers and programming for a reason people

    moved
     
  4. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    btw, that's not vb.net, it's vb
     
  5. VBGOD

    VBGOD Guest

    Wait!

    Which one is it? For starters, do you want it to be a decimal number? For starters, declare the variable as Decimal.

    Code:
            Dim rate As String = InputBox("Enter a Decimal number.", "What is rate?")
    
            If rate.Trim = "" Then
                ' Do or say something
                Exit Sub
            End If
    
            If IsNumeric(rate) = False Then
                ' Do or say something
                Exit Sub
            End If
    
            MessageBox.Show(Convert.ToDecimal(rate))
    
     

Share This Page