-
Calling a function
Having a problem with parsing my declaration and converting into a label.
Heres what i got so far:
Private Function TaxAmount(ByVal TaxAmountDecimal As Decimal) As Decimal
'Declare variable for calculations.
Dim OutputSubtotal_Decimal As Decimal
'Determine tax amount.
Return 0.08D * OutputSubtotal_Decimal
End Function
Private Sub ColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorToolStripMenuItem.Click
'Declare the variables.
Dim TaxDecimal As Decimal
Dim AmountDue_Decimal As Decimal
Dim CarSalesPrice_Decimal As Decimal
Dim Accessories_Decimal As Decimal
Dim OutputSubtotal_Decimal As Decimal
Dim OutputTotal_Decimal As Decimal
Dim TaxAmount_Decimal As Decimal
Dim TradeInAllowance_Decimal As Decimal
Try
'Convert the Car Sales Price textbox input data.
CarSalesPrice_Decimal = Decimal.Parse(CarSalesPriceTextBox.Text)
Try
'Convert the Trade-In-Allowance textbox input data.
If TradeInAllowanceTextBox.Text = "" Then
TradeInAllowance_Decimal = 0
Else
TradeInAllowance_Decimal = Decimal.Parse(TradeInAllowanceTextBox.Text)
End If
If StereoSystemCheckBox.Checked Then
Accessories_Decimal += STEREOSYSTEM_Decimal
End If
If LeatherInteriorCheckBox.Checked Then
Accessories_Decimal += LEATHERINTERIOR_Decimal
End If
If ComputorNavigationCheckBox.Checked Then
Accessories_Decimal += COMPUTERNAVIGATION_Decimal
End If
'Determine the Amount due.
OutputSubtotal_Decimal = CarSalesPrice_Decimal + Accessories_Decimal
OutputTotal_Decimal = OutputSubtotal_Decimal + TaxDecimal
AmountDue_Decimal = OutputTotal_Decimal - TradeInAllowance_Decimal
TaxDecimal = OutputSubtotal_Decimal + TaxAmount_Decimal
'Display the information.
AmountLabel.Text = AmountDue_Decimal.ToString("c2")
AccessoriesLabel.Text = Accessories_Decimal.ToString
OutputSubTotalLabel.Text = OutputSubtotal_Decimal.ToString
TaxDecimal = Decimal.Parse(TaxLabel.Text)
TaxLabel.Text = TaxAmount(TaxDecimal).ToString
OutputTotalLabel.Text = OutputTotal_Decimal.ToString("C")
TradeInAllowanceTextBox.Text = TradeInAllowance_Decimal.ToString
Catch TradeInAllowanceException As FormatException
MessageBox.Show("Trade-In value must be numeric data.", "Data Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With TradeInAllowanceTextBox
.Focus()
.SelectAll()
End With
End Try
I'm trying to calculate the amount due thru the menu item: Calculate and I need to call the tax amount through a function. I hope this makes sense.
I keep getting a message box saying invalid data for the trade-in textbox.
-
Re: Calling a function
You will probably have noticed in your other threads how people keep posting code snippets that are easier to read because they are formatted. Please use the Code or VBCode buttons provided to do so with your own code snippets. If you use the Code button then you can also highlight using bold, italic or colour to point us to exactly where the issue is. The easier you make it for us to help, the more likely we will.