title: Checking for numeric value entered in text box in Visual Basic
body: <p>I am working on a program for my Visual Basic class and have a quick question. One of the things we were encouraged to do was to check to make sure the quantity entered in a text box is actually a number. Our professor suggested using IsNumeric to perform this check, but I'm running into some trouble. I already had a good bit of the code written before he added this to the instructions, so not sure how to integrate this into the code I already have. </p>
  
  <p>The main purpose of the program is to allow the user to add ingredients from one list box to the recipe list box, input a quantity for each selected ingredient in a text box, and calculate the total calories for the recipe. The way I have the code written now, IsNumeric is part of a nested if statement at the beginning of where I will start adding the selected ingredients to  the recipe list box. I'm not sure if that's the correct place for it though.</p>
  
  <p>Here is the code I have written so far.</p>
  
  <pre><code>Public Class Form1
  
      Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
          Dim i As Integer = lstIngredients.SelectedIndex
          Dim Quantity As Double
          Dim intCount As Integer = 0
  
          If Trim(txtQuantity.Text = "") Then
              Quantity = 1
          Else
              Quantity = Me.txtQuantity.Text
          End If
  
          If txtQuantity.Text Is IsNumeric() Then
              If intCount &lt; Quantity Then
                  lstRecipe.Items.Add(Quantity &amp; " " &amp; lstIngredients.Text)
                  intCount += 1
              End If
          Else
              MessageBox.Show("The quantity entered is not numeric. Please add a numeric    quantity.")
          End If
  
  
      End Sub
  
      Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
          lstRecipe.Items.Clear()
          txtQuantity.Clear()
          txtAnswer.Clear()
      End Sub
  
      Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
  
  
      End Sub
  End Class
  </code></pre>
  
  <p>Also, here is the error I receive when I attempt to run this program as it is written. </p>
  
  <pre><code>Error   1   Argument not specified for parameter 'Expression' of 'Public   Function IsNumeric(Expression As Object) As Boolean'.    
  </code></pre>
  
  <p>Any suggestions would be greatly appreciated. </p>