|
-
October 19th, 2009, 10:50 PM
#1
Calculation problems
I was hoping someone could tell me why my code isnt working.
Basically i'm trying to calculate totals and whenever I run the program the calculations comes out to zero. here is what i have for the calculations
'Declare Constants
Const YACHT_SIZE_22_Decimal As Decimal = 95D
Const YACHT_SIZE_24_Decimal As Decimal = 137D
Const YACHT_SIZE_30_Decimal As Decimal = 160D
Const YACHT_SIZE_32_Decimal As Decimal = 192D
Const YACHT_SIZE_36_Decimal As Decimal = 250D
Const YACHT_SIZE_38_Decimal As Decimal = 400D
Const YACHT_SIZE_45_Decimal As Decimal = 550D
Private Sub OkButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OkButton.Click
'Calculate and display the current amounts and add to totals.
Dim PriceDecimal, CharterPriceDecimal As Decimal
Dim NumberOfHoursInteger As Integer
'Find the Price.
If YachtSizeList.SelectedIndex = 22 Then
PriceDecimal = YACHT_SIZE_22_Decimal
ElseIf YachtSizeList.SelectedIndex = 24 Then
PriceDecimal = YACHT_SIZE_24_Decimal
ElseIf YachtSizeList.SelectedIndex = 30 Then
PriceDecimal = YACHT_SIZE_30_Decimal
ElseIf YachtSizeList.SelectedIndex = 32 Then
PriceDecimal = YACHT_SIZE_32_Decimal
ElseIf YachtSizeList.SelectedIndex = 36 Then
PriceDecimal = YACHT_SIZE_36_Decimal
ElseIf YachtSizeList.SelectedIndex = 38 Then
PriceDecimal = YACHT_SIZE_38_Decimal
ElseIf YachtSizeList.SelectedIndex = 45 Then
PriceDecimal = YACHT_SIZE_45_Decimal
End If
'Calculate the extended price and add to order total
Try
NumberOfHoursInteger = Integer.Parse(HoursTextBox.Text)
CharterPriceDecimal = PriceDecimal * NumberOfHoursInteger
PriceTextBox.Text = CharterPriceDecimal.ToString("C")
'Allow Clear after an order has begun
ClearForNextCharterToolStripMenuItem.Enabled = True
ClearButton.Enabled = True
Catch NumberOfHoursException As FormatException
MessageBox.Show("Quantity must be numeric.", "Data entry error", MessageBoxButtons.OK, MessageBoxIcon.Error)
With HoursTextBox
.Focus()
.SelectAll()
End With
End Try
End Sub
I dont know if this is enough info to help me.. just let me know. Really would appreciate any insite on to why my totals come out to $0.00 when calculate the total
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|