Kedwards5 0 Newbie Poster

When I input the number in stock it always returns the number ordered as being both back ordered and ready to ship. Please Help!!!!

Public Class Form1

' Class-level declarations
Const decDELIVERY_CHARGE As Decimal = 10D
Const decRUSH_DELIVERY As Decimal = 15D
Const decSPOOL_OF_COOPER As Decimal = 100D


Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim intSpoolsReady As Integer
Dim intSpoolsOrdered As Integer
Dim intSpoolsBackOrdered As Integer
Dim intSpoolsTotal As Integer
Dim decShippingTotal As Decimal
Dim decTotalDue As Decimal
Dim intSpoolsInStock As Integer


'Call the GetInStock Function
GetInStock()

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

' Get the number of spools ready to ship
intSpoolsReady = GetReady(intSpoolsOrdered, intSpoolsInStock, intSpoolsReady, intSpoolsBackOrdered)
lblReadyToShip.Text = intSpoolsReady.ToString

' Get the number of spools on backorder
intSpoolsBackOrdered = GetBackOrder(intSpoolsInStock, intSpoolsOrdered, intSpoolsBackOrdered)
lblBackOrdered.Text = intSpoolsBackOrdered.ToString

' Get the shipping and handling cost
decShippingTotal = ShippingCharges(intSpoolsReady, decShippingTotal)
lblShippingCharges.Text = decShippingTotal.ToString("c")

'Get Spools total
intSpoolsTotal = CInt(intSpoolsOrdered * decSPOOL_OF_COOPER)

' Get the total due
decTotalDue = intSpoolsTotal + decShippingTotal
lblTotal.Text = decTotalDue.ToString("c")


End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
' Exit form
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

Function GetInStock() As Integer
' This function displays an input box asking the user to enter
' the number of spools in stock.
Dim strInput As String
Dim intSpoolsInStock As Integer

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


Return intSpoolsInStock
End Function

Function GetReady(ByVal intSpoolsOrdered As Integer, ByVal intSpoolsInStock As Integer, ByVal intSpoolsReady As Integer, ByVal intSpoolsBackOrdered As Integer) As Integer


If intSpoolsOrdered <= intSpoolsInStock Then
intSpoolsReady = intSpoolsOrdered
ElseIf intSpoolsOrdered > intSpoolsInStock Then
intSpoolsReady = intSpoolsOrdered - intSpoolsBackOrdered

End If
Return intSpoolsReady
End Function

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


If intSpoolsOrdered <= intSpoolsInStock Then
intSpoolsBackOrdered = 0
ElseIf intSpoolsOrdered > intSpoolsInStock Then
intSpoolsBackOrdered = intSpoolsOrdered - intSpoolsInStock
End If
Return intSpoolsBackOrdered
End Function

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


If chkRush.Checked = True Then
decShippingTotal = 15 * intSpoolsReady

Else
decShippingTotal = 10 * intSpoolsReady

End If
Return decShippingTotal
End Function

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

' Reset the focus to the first field
txtSpoolsOrdered.Focus()
End Sub

Private Sub ResetDelivery()
' This procedure clears the labels that display the delivery info.
lblBackOrdered.Text = String.Empty
lblReadyToShip.Text = String.Empty
lblShippingCharges.Text = String.Empty
lblTotal.Text = String.Empty
End Sub
End Class