I have a problem with a program I have been assigned that's driving me crazy(short trip)and I hope someone could point me in the right direction. I'm using Visual Basic 2005 on Win7 and the program is a Windows Form application.
The application has to calculate a total order for wire spools and display the shipping status. The form has a text box to accept the total number of spools being ordered (Integer), labels to display # In Stock, # on Back Order, Shipping & Handling, and Order Total, and buttons for calculate, clear, and exit. The application has four functions called from the Calculate Total button's click event procedure.
It is not calculating the shipping charges and giving me a total, or calculating the rush charge if checked, or validating my input by not accepting orders for less than 1 spool, also if there are no backordered spools it should return zero. I have fooled with this until I'm sure I have over thought it and over complicated it
When I run the code it will take the number of spools ordered and then ask me for how many are in stock; it will calculate if the amount ordered is greater and the amount in stock is less and then put the difference in the back ordered box. This is my first class in VB and I just don't have the hang of it yet. Any help or suggestions will be appreciated.
Public Class Form1
Private Function GetInStock() As Integer
Dim intSpoolinStock As Integer = InputBox("Enter the number of spools in stock")
Return intSpoolinStock
End Function
Private Function ReadyToShip() As Integer
Dim intSpoolReadyShip As Integer
Return intSpoolReadyShip
End Function
Private Function BackOrdered() As Integer
End Function
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
' This procedure calculates the status and total of an order of spools.
Dim decSpoolsTotal As Decimal ' Holds the total cost of spools ordered
Dim decTotalDue As Decimal ' Holds the order total
Dim decShipping As Decimal ' Holds the shipping charges
Dim intReady As Integer ' Holds the spools ready to ship
Dim intBackOrder As Integer ' Holds the spools on back order
Dim intSpoolsOrdered, intSpoolInStock, intSpoolReadyShip As Integer
Dim intSpoolsOnBackOrder As Integer
intReady = ReadyToShip()
txtSpoolsReadyToShip.Text = intReady.ToString("d")
intBackOrder = BackOrdered()
txtSpoolsOnBackOrder.Text = intBackOrder.ToString("d")
decShipping = ShippingCharges()
txtShippingHandling.Text = decShipping.ToString("c")
txtTotalDue.Text = decTotalDue.ToString("c")
decSpoolsTotal = ReadyToShip() * 100D
decTotalDue = ShippingCharges() + decSpoolsTotal
intSpoolInStock = GetInStock()
intSpoolReadyShip = (intSpoolInStock)+(intSpoolsOrdered)
txtSpoolsReadyToShip.Text = intSpoolReadyShip.ToString
intSpoolsOnBackOrder = (intSpoolsOrdered) - (intSpoolInStock)
txtSpoolsOnBackOrder.Text = intSpoolsOnBackOrder.ToString
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
ChkRushDelivery.Checked = False
txtNumberSpoolsOrdered.Clear()
txtSpoolsReadyToShip.Clear()
txtSpoolsOnBackOrder.Clear()
txtShippingHandling.Clear()
txtTotalDue.Clear()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
' End the application
Me.Close()
End Sub
Function ShippingCharges() As Decimal
' This function returns the cost of shipping.
Dim decTotalShipping As Decimal ' Holds the total shipping cost
txtNumberSpoolsOrdered.CausesValidation = False
If ChkRushDelivery.Checked = True Then
decTotalShipping = ReadyToShip() * 15D
Else
decTotalShipping = ReadyToShip() * 10D
End If
Return decTotalShipping
End Function
End Class

New Topic/Question
Reply



MultiQuote








|