Jump to content

Hello, so I am trying to create a basic program that allows the user to enter the number of things purchased and it tells shipping charge. Here is what I have so far. My problem is that When calculating the price is not shown up correctly. I'm sure I'm doing something very wrong but not sure What. Their is probably unnecessary code. First Column Is Min orders for that shipping price. 2nd is Max orders for that shipping price and 3rd is the Shipping price. Thank you. PS.

txtOrdered is where user enters amount and lblShipping is where result should display, but you probably know that ;) 

 

Private Shipping(,) As Double =
           {{1, 5, 10.99},
           {6, 10, 7.99},
           {11, 20, 3.99},
           {21, 9999999, 0}}

    Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
        Dim NumberOrdered As Double
        Double.TryParse(txtOrdered.Text, NumberOrdered)
        Dim Row As Integer
        Dim ShippingCharge As Double
        Dim Bound As Double = Shipping.GetUpperBound(0)
        Dim Bound1 As Double = Shipping.GetUpperBound(1)

        NumberOrdered = Shipping(0, 1)
        Row = +1


        If Row <= Bound AndAlso Row <= Bound1 Then

            Shipping(Row, 2) = ShippingCharge

            lblShipping.Text = ShippingCharge.ToString
        End If
    End Sub

 

Link to comment
https://linustechtips.com/topic/739332-visual-basic-array-help/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×