Hello,

I am having issues creating an application that is due tomorrow! Obviously I am not calling my functions correctly, or I just don't even have my functions written correctly. Please help!! Here is the problem:

I am trying to create an application for a wire company that sells spools of wire for $100 each. The normal delivery charge is $10 per spool. Rush delivery costs $15 per spool. The user should enter the number of spools ordered in a text box, and check Rush Delivery box if rush delivery is desired. When the Calculate Total button is clicked, an input box should appear asking the user to enter the number of spools currently in stock. If the user has ordered more spools than are in stock, a portion of the order is back-ordered. For example, if the user orders 200 spools and there are only 150 spools in stock, then 150 spools are ready to ship and 50 spools are back-ordered.

Attached is the code with comments on what each function is supposed to do.
Any help would be greatly appreciated!!!

' Program Discription: This application is an order form for a wire
' company that sells spools of copper wiring for $100 each. Delivery charge
' is $10 per spool, $15 for rush delivery. The app displays the status of the
' order including: 1. the number of spools ready to ship; 2. The number of spools
' on back order; 3. the shipping and handling charges; 4. the total amount due.
' The user enters the number of spools and if they want rush delivery. When the
' Calculate Total button is clicked, an input box appears asking the user to enter
' the number of spools currently in stock.

Public Class Form1

    Private Sub btnCalc_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnCalc.Click

        Dim intSpoolsOrdered As Integer ' The number of spools ordered
        Dim intSpoolsInStock As Integer ' The number of spools in stock
        Dim intReady As Integer         ' Holds the spools ready to ship 
        Dim intBackOrder As Integer     ' Holds the spools on back order 
        Dim intSpoolsTotal As Integer   ' Holds the total cost of spools ordered 
        Dim decShipping As Decimal      ' Holds the shipping charges 
        Dim decOrderTotal As Decimal    ' Holds the order total 

        ' Call the GetInStock Function
        GetInStock()

        ' The number of spools the user's wants to order
        intSpoolsOrdered = CInt(txtSpoolsOrdered.Text)

        ' Calculate the Total Cost of Spools ordered
        intSpoolsTotal = intSpoolsOrdered * 100
        decOrderTotal = ShippingCharges(intReady, decShipping) + intSpoolsTotal

        'intReady = ReadyToShip(intSpoolsInStock, intSpoolsOrdered)
        'lblReadyShip.Text = intReady.ToString()
        lblReadyShip.Text = ReadyToShip(intSpoolsInStock, intSpoolsOrdered).ToString()
        intBackOrder = BackOrdered(intSpoolsInStock, intSpoolsOrdered)
        lblBackOrder.Text = intBackOrder.ToString()
        decShipping = ShippingCharges(intReady, decShipping)
        lblShipHandle.Text = decShipping.ToString("c")
        lblTotalDue.Text = decOrderTotal.ToString("c")


    End Sub

    Function GetInStock() As Integer
        ' This function displays an input box asking the user to 
        ' enter the number of spools in stock. The function returns
        ' the value entered by the user.

        Dim strInput As String          ' Holds the user's input
        Dim intSpoolsInStock As Integer ' Holds the number of spools in stock

        strInput = InputBox("How many spools are in " _
            & "stock? ", "Spools in Stock")
        intSpoolsInStock = CInt(strInput)

        Return intSpoolsInStock

    End Function

    Function ReadyToShip(ByVal intSpoolsInStock As Integer, ByVal intSpoolsOrdered As Integer) _
        As Integer
        ' This function accepts the number of spools in stock and
        ' the number of spools ordered. The function returns the
        ' number of spools ready to ship.

        Dim intReady As Integer   ' Holds the spools ready to ship 
        If intSpoolsOrdered < intSpoolsInStock Then
            intReady = intSpoolsOrdered
        Else
            intReady = intSpoolsInStock - intSpoolsOrdered
        End If

        Return intReady

    End Function

    Function BackOrdered(ByVal intSpoolsInStock As Integer, ByVal intSpoolsOrdered As Integer) _
        As Integer
        ' This function accepts the number of spools in stock and
        ' the number of spools ordered. The function returns the
        ' number of spools on back order. If no spools are on back
        ' order, return 0.

        Dim intBackOrder As Integer     ' Holds the spools on back order 

        If intSpoolsInStock > intSpoolsOrdered Then
            intBackOrder = 0
        Else
            intBackOrder = intSpoolsInStock - intSpoolsOrdered
        End If

        Return intBackOrder

    End Function

    Function ShippingCharges(ByVal intReady As Integer, ByVal decShipping As Decimal) _
        As Decimal
        ' This function accepts the number of spools in ready to ship
        ' and the per-spool shipping charges. The function returns the
        ' total shipping and handling charges.

        If chkRush.Checked = True Then
            decShipping = 15D * CDec(intReady)
        Else
            decShipping = 10D * CDec(intReady)
        End If

        Return decShipping

    End Function

    Private Sub btnExit_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnExit.Click

        ' End the Application by closing the window.
        Me.Close()

    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnClear.Click

        ' This procedure resets the controls to default values 

        ResetSpools()
        ResetDelivery()

    End Sub

    Private Sub ResetSpools()
        ' This procedure resets the text box and the check box.
        txtSpoolsOrdered.Clear()
        chkRush.Checked = False

        ' Reset the focus to the first fiels
        txtSpoolsOrdered.Focus()

    End Sub

    Private Sub ResetDelivery()
        ' This procedure clears the labels that display the delivery info.
        lblReadyShip.Text = String.Empty
        lblBackOrder.Text = String.Empty
        lblShipHandle.Text = String.Empty
        lblTotalDue.Text = String.Empty

    End Sub

End Class

I Hope you already solvet it at due time.

Pay attention to the compare you are doing because you are missing the case when the current stock and the ordered quantity are equals.

On the Ready to ship function, when the current stock is smaller than the requested quantity, the returned value should be the current stock, as you will deliver all the current stock, else the returned value should be the ordered quantity.

On the Back Ordered function, when the current stock is smaller than the requested quantity, the returned value should be the ordered value minus the current stock as you will deliver all the current stock, else the returned value should be 0.

Probably this way will work.
Hope this helps.

Hello,

I am having issues creating an application that is due tomorrow! Obviously I am not calling my functions correctly, or I just don't even have my functions written correctly. Please help!! Here is the problem:

I am trying to create an application for a wire company that sells spools of wire for $100 each. The normal delivery charge is $10 per spool. Rush delivery costs $15 per spool. The user should enter the number of spools ordered in a text box, and check Rush Delivery box if rush delivery is desired. When the Calculate Total button is clicked, an input box should appear asking the user to enter the number of spools currently in stock. If the user has ordered more spools than are in stock, a portion of the order is back-ordered. For example, if the user orders 200 spools and there are only 150 spools in stock, then 150 spools are ready to ship and 50 spools are back-ordered.

Attached is the code with comments on what each function is supposed to do.
Any help would be greatly appreciated!!!

' Program Discription: This application is an order form for a wire
' company that sells spools of copper wiring for $100 each. Delivery charge
' is $10 per spool, $15 for rush delivery. The app displays the status of the
' order including: 1. the number of spools ready to ship; 2. The number of spools
' on back order; 3. the shipping and handling charges; 4. the total amount due.
' The user enters the number of spools and if they want rush delivery. When the
' Calculate Total button is clicked, an input box appears asking the user to enter
' the number of spools currently in stock.

Public Class Form1

    Private Sub btnCalc_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnCalc.Click

        Dim intSpoolsOrdered As Integer ' The number of spools ordered
        Dim intSpoolsInStock As Integer ' The number of spools in stock
        Dim intReady As Integer         ' Holds the spools ready to ship 
        Dim intBackOrder As Integer     ' Holds the spools on back order 
        Dim intSpoolsTotal As Integer   ' Holds the total cost of spools ordered 
        Dim decShipping As Decimal      ' Holds the shipping charges 
        Dim decOrderTotal As Decimal    ' Holds the order total 

        ' Call the GetInStock Function
        GetInStock()

        ' The number of spools the user's wants to order
        intSpoolsOrdered = CInt(txtSpoolsOrdered.Text)

        ' Calculate the Total Cost of Spools ordered
        intSpoolsTotal = intSpoolsOrdered * 100
        decOrderTotal = ShippingCharges(intReady, decShipping) + intSpoolsTotal

        'intReady = ReadyToShip(intSpoolsInStock, intSpoolsOrdered)
        'lblReadyShip.Text = intReady.ToString()
        lblReadyShip.Text = ReadyToShip(intSpoolsInStock, intSpoolsOrdered).ToString()
        intBackOrder = BackOrdered(intSpoolsInStock, intSpoolsOrdered)
        lblBackOrder.Text = intBackOrder.ToString()
        decShipping = ShippingCharges(intReady, decShipping)
        lblShipHandle.Text = decShipping.ToString("c")
        lblTotalDue.Text = decOrderTotal.ToString("c")


    End Sub

    Function GetInStock() As Integer
        ' This function displays an input box asking the user to 
        ' enter the number of spools in stock. The function returns
        ' the value entered by the user.

        Dim strInput As String          ' Holds the user's input
        Dim intSpoolsInStock As Integer ' Holds the number of spools in stock

        strInput = InputBox("How many spools are in " _
            & "stock? ", "Spools in Stock")
        intSpoolsInStock = CInt(strInput)

        Return intSpoolsInStock

    End Function

    Function ReadyToShip(ByVal intSpoolsInStock As Integer, ByVal intSpoolsOrdered As Integer) _
        As Integer
        ' This function accepts the number of spools in stock and
        ' the number of spools ordered. The function returns the
        ' number of spools ready to ship.

        Dim intReady As Integer   ' Holds the spools ready to ship 
        If intSpoolsOrdered < intSpoolsInStock Then
            intReady = intSpoolsOrdered
        Else
            intReady = intSpoolsInStock - intSpoolsOrdered
        End If

        Return intReady

    End Function

    Function BackOrdered(ByVal intSpoolsInStock As Integer, ByVal intSpoolsOrdered As Integer) _
        As Integer
        ' This function accepts the number of spools in stock and
        ' the number of spools ordered. The function returns the
        ' number of spools on back order. If no spools are on back
        ' order, return 0.

        Dim intBackOrder As Integer     ' Holds the spools on back order 

        If intSpoolsInStock > intSpoolsOrdered Then
            intBackOrder = 0
        Else
            intBackOrder = intSpoolsInStock - intSpoolsOrdered
        End If

        Return intBackOrder

    End Function

    Function ShippingCharges(ByVal intReady As Integer, ByVal decShipping As Decimal) _
        As Decimal
        ' This function accepts the number of spools in ready to ship
        ' and the per-spool shipping charges. The function returns the
        ' total shipping and handling charges.

        If chkRush.Checked = True Then
            decShipping = 15D * CDec(intReady)
        Else
            decShipping = 10D * CDec(intReady)
        End If

        Return decShipping

    End Function

    Private Sub btnExit_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnExit.Click

        ' End the Application by closing the window.
        Me.Close()

    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnClear.Click

        ' This procedure resets the controls to default values 

        ResetSpools()
        ResetDelivery()

    End Sub

    Private Sub ResetSpools()
        ' This procedure resets the text box and the check box.
        txtSpoolsOrdered.Clear()
        chkRush.Checked = False

        ' Reset the focus to the first fiels
        txtSpoolsOrdered.Focus()

    End Sub

    Private Sub ResetDelivery()
        ' This procedure clears the labels that display the delivery info.
        lblReadyShip.Text = String.Empty
        lblBackOrder.Text = String.Empty
        lblShipHandle.Text = String.Empty
        lblTotalDue.Text = String.Empty

    End Sub

End Class
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.