Need help building a Shipping Calc with some limitation really confused on how to word and code this program. Below is the code I already have after creating the form.

This is my assignment

Weight of the Package (in kilograms) / Shipping rate per Mile
2kg or less / $0.01
over 2kg, but not more than 6kg /$0.015
over 6kg, but not more than 10kg /$0.02
over 10kg, but not more than 20kg / $0.025

Input validation: Do not accept values of 0 or less for the weight of the package. Do not accept weights of more than 20 kg(this is the maximum weight the company will ship) Do not accept distances of less than 10 miles or more than 3000 miles. These are the company's minimum and maximum shipping distances.

Public Class Form1

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub lblRates_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ' Clear the data entered in the form and give focus back to the Weight of Package
        txtDistance.Clear()
        txtWeight.Clear()
        lblShipcost.Text = String.Empty
        txtDistance.Focus()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' Close the form 
        Me.Close()
    End Sub

    Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
        ' Setting up values for  Values
        Dim txtWeight As Decimal
        Dim txtDistance As Decimal
        Dim lblShipcost As Decimal



    End Sub
End Class

Once you have eliminated and flagged bad input values, the setting of the rate is simple when you realize that you have several cases. The first case is weight <= 2 kg, the second is weight <= 6, etc. That translates nicely into a select case structure. As long as you go from lowest to highest weight it will work the way you want. Is that enough of a hint?

Try hard, it's a matter of validation and then proceed to calculation after.

commented: Doesn't contribute anything. -2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.