Do Until EOF Loop With Records In VB 2010 - Stack Overflow

I have a program below that doesn't seem to be doing what I want it to do. In general, the pseudocode is: enter the number of miles (miles.text), click button, check: is the mileage entered equal to or less than the mileage radius (milestotextbox) in the database? If so, grab the truckload rate that corresponds to that radius (truckloadratetext) and display it in a textbox called "rate" (rate.text) and if not, continue looking until EOF. I've shown the code below. It lets me enter the mileage but won't check and display the result.

The data in the table looks like this:

ID MILESTO TRUCKLOADRATE 1 50 200 2 100 300 3 200 700 4 300 800

So if someone enters a mileage like 10, I want it to take the truckload rate of $200. If someone enters 250, the rate would then be 800. I'm not too hung up right now about what happens if a mileage is out of range. Just trying to figure out why the mechanics of something like this isn't working. It's my first time using records with a LOOP command so I'm trying to keep it straightforward with my program.

What could I be doing wrong? Thank you in advance and hope all has a great New Years!

Public Class Form1 Private Property EOF As Boolean 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 '_test_2DataSet.test' table. You can move, or remove it, as needed. Me.TestTableAdapter.Fill(Me._test_2DataSet.test) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Do Until EOF() If Val(MilestoTextBox.Text) <= Val(Miles.Text) Then rate.Text = TruckloadTextBox.Text End If Loop End Sub End Class

Từ khóa » Visual Basic Do Until Eof