Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7011317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:06:41+00:00 2026-05-27T22:06:41+00:00

I have a program below that doesn’t seem to be doing what I want

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:06:42+00:00Added an answer on May 27, 2026 at 10:06 pm

    Sorry for the delay in answering the question here and I want to thank everyone who answered, especially Tim.

    In summary, Where a user wants to search through a dataset and compare a user-inputted value against some kind of index (in my case, if a mileage entered is less than or equal to some boundary value) and get the corresponding record that satisfies that criteria, the solution that works (thank you Tim!) is:

    Dim mileAge = Int32.Parse(Miles.Text) 
    Dim rate = 0
    For Each row In _test_2DataSet.test
        If mileAge <= row.MILESTO Then
            rate = row.TRUCKLOADRATE
            Exit For
        End If
    Next
    If rate <> 0 Then
        TxtRate.Text = rate.ToString
    End If
    

    In the example, mileage is converted to a value that can be used to compare against a column in the dataset called MILESTO, which is a mile radius that corresponds to a price for transporting goods called TRUCKLOADRATE. The program iterates through each row in the dataset until the condition that mileage <= row.MILESTO is satisfied.

    My original thought was using a search until EOF and this method works better.

    Thanks all and again my apologies for the delay in summing this up for other users.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have program that runs fast enough. I want to see the number of
Below I have written a sample program that I have written to learn about
I have a program that uses the mt19937 random number generator from boost::random. I
below i have a code that runs in most of my simple programs ..
I have the below command line arguments set for the program. argument proc is
I have program that has a variable that should never change. However, somehow, it
I have program, that must interact with a console program before my program can
I have a program that spits out both standard error and standard out, and
I have a program that creates a Windows user account using the NetUserAdd() API
I am very new to jQuery and javascript programming. I have a program below

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.