title: manipulating textbox variables in calculations
body: <p>I have some code where I am trying to use variables in a tabpage. The first tabpage only has one text box for user entry (miles.text) and a button to do a calculation: traveltime = mileage/speed. The value from miles.text is stored into a variable called mileage while the speed used is stored in a variable called speed (me.speedtextbox.text). </p>
  
  <p>Ordinarily, doing val(variable.text) works like a charm and it's not doing it in this case. When the user enters 100 for the mileage, it should be divided by 65 (the number in the database) and, therefore, the answer should be 1.53 hours. In my case, I'm getting "infinity" and whenever I do anything else with the variable, I get "when casting from a number, the value must be a number less than infinity." But it is! It's only 65 and I double-checked that the dataset said that too, which it does. Not sure why I am getting this error...thank you!</p>
  
  <pre><code>Public Class Form1
  
      Private Property Traveltime As Decimal
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          'TODO: This line of code loads data into the 'fooDataSet.testdata' table. You can move, or remove it, as needed.
          Me.TestdataTableAdapter.Fill(Me.foouDataSet.testdata)
  
      End Sub
  
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
          Dim mileage As Integer
          Dim speed As Integer
  
  
          mileage = Val(miles.Text)
          speed = Val(Me.SpeedTextBox.Text)
          traveltime = mileage / speed
  
          txttraveltime.text = Traveltime.ToString
  
      End Sub
  
      Private Sub txtrate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txttraveltime.TextChanged
  
      End Sub
  End Class
  </code></pre>
  
  <p>So I did a test program where it did only one thing and that was to simply read one data column in a one row database and store it to a local variable and multiply it by 1.60  except now I am getting "reference to a non-shared member requires an object reference" and it doesn't seem to recognize Me.Speed when I declare it. What am I doing wrong? </p>
  
  <pre><code>Public Class Form1
  
      Dim Speed As Object
      Dim Me.Speed As New Speed
  
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
          Me.Speed = CDec(fooDataSet.testdataRow.Item("speed"))*1.60
          Speedtextbox.text = Me.Speed.tostring
  
      End Sub
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          'TODO: This line of code loads data into the 'fooDataSet.testdata' table. You can move, or remove it, as needed.
          Me.TestdataTableAdapter.Fill(Me.fooDataSet.testdata)
  
      End Sub
  End Class
  </code></pre>