3 Replies - 901 Views - Last Post: 18 December 2013 - 06:58 AM Rate Topic: -----

#1 peper  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-December 13

School is over, I never solved this one. Help PLEASE

Posted 18 December 2013 - 01:37 AM

School is over and try as I might I never solved this one and truth be told I just have to know. The user should enter the number of spools ordered into the text box. When the CALCULATE TOTAL button is clicked an input box should appear asking how many spools are currently in stock. If the user enters more spools than are on hand then a back order is created.

  Dim lblSandD As Object
    Dim lblTotalDue As Object
    Dim lblShipH As Object
    Dim intSpoolsOrdered As Object
    Dim lblReadyShip As Integer

    Private Property txtSpoolsOrdered As Object

    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 Char ' The number of spools in stock
        Dim intReadyToShip 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 decSandH As Decimal      ' Holds the shipping charges 
        Dim decTotal As Decimal    ' Holds the order total 
        ' Call the GetInStock Function
        GetInStock()
        ' The number of spools the user wants to order

        ' Calculate the Total Cost of Spools ordered
        intSpoolsTotal = intSpoolsOrdered * 100
        decTotal = ShippingCharges(intReadyToShip, decSandH) + intSpoolsTotal
        'intReady = ReadyToShip(intSpoolsInStock, intSpoolsOrdered)
        'lblReadyShip.Text = intReady.ToString()
        lblReadyToShip.Text = ReadyToShip(Val(intSpoolsInStock), intSpoolsOrdered).ToString()
        intBackOrder = BackOrdered(Val(intSpoolsInStock), intSpoolsOrdered)
        lblBackOrder.Text = intBackOrder.ToString()
        decSandH = ShippingCharges(intReadyToShip, decSandH)
        lblSandH.Text = decSandH.ToString("c")
        lblTotal.Text = decTotal.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")
        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 lblReadyShip
    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 chkRushD.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.
        txtNumberSpools.Clear()
        chkRushD.Checked = False
        ' Reset the focus to the first fiels
        txtNumberSpools.Focus()
    End Sub
    Private Sub ResetDelivery()
        ' This procedure clears the labels that display the delivery info.
        lblReadyToShip.Text = String.Empty
        lblBackOrder.Text = String.Empty
        lblSandH.Text = String.Empty
        lblTotal.Text = String.Empty
    End Sub

    Private Sub lblSandH_Click(sender As Object, e As EventArgs) Handles lblSandH.Click

    End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Replies To: School is over, I never solved this one. Help PLEASE

#2 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3177
  • View blog
  • Posts: 10,639
  • Joined: 12-December 12

Re: School is over, I never solved this one. Help PLEASE

Posted 18 December 2013 - 04:44 AM

This is VB.NET, not VB6. Topic moved.

VB 2005, 2008, etc., are all versions of VB.NET.
Was This Post Helpful? 0
  • +
  • -

#3 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 177
  • View blog
  • Posts: 1,089
  • Joined: 11-May 12

Re: School is over, I never solved this one. Help PLEASE

Posted 18 December 2013 - 06:38 AM

Ok, I see your code, but I don't see a question. Is there a specific problem in your program, is it not working how you expected? We need more information.
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: School is over, I never solved this one. Help PLEASE

Posted 18 December 2013 - 06:58 AM

Can you elaborate on what your actual question is?
We tend to work off of the problems you describe.

Just a quick glance a couple of things stuck out

1. You declare intspoolsintstock as a Char but your remark reads Number of spools in stock.
2. Your function GetInStock states that it returns something but I don't see where you're storing that returned value
Typically when a function returns something required for a calculation or to output to the user it is either called as part of the calculation or its return is assigned to a variable (ie, someVariable = MyFunctionThatReturnsAResult())
3. the next line, after the GetInStock function call then performs a calculation to get a value for intSpoolsTotal but a variable (intSpoolsOrdered) in that calculation was never set to anything after it was declared, which by the way would default to 0 and as you know 0 * anything = 0

Here's what I suggest:
Read through this Debugging Tutorial and then step/work through your code as it process to find out where your issues are. Then when you find something you don't know how to resolve, post back here with a description of your issue and someone will help you resolve it.

This post has been edited by CharlieMay: 18 December 2013 - 06:58 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1