M
Michael MacDonald
I have written a simple program that calculates a running $ total. This
program uses a checkbox to acknowledge that that version of the ticket
is desired and it checks the Qty box to see how many tickets are
desired. Based upon the checkbox being checked and the number of tickets
desired directly affects the running grand total (of course!). OK I
have set where if ticketsDesiredTotal>0 then checkbox.checked = true.
The only problem I have is that if the user deletes the number of
tickets and the user does not enter a number and “ ” is in the tickets
desired box the program crashes. It crashes because it is taking the
value of TicketsDesiredTotal and multiplying it by the per ticket cost.
And the debugger says it can’t convert “” to use it in the equation.
How can I make this thing work??? Here is the code and the function it
calls:
Function processor()
Dim decTtl As Decimal = 0.0
Dim strOil As String = txtQtyOil.Text
If cbOil.Checked = True Then
lblOilTtl.Text = (txtQtyOil.Text * 150.0)
decTtl += lblOilTtl.Text
End If
If cbAllies.Checked = True Then
lblAlliesTtl.Text = (txtQtyAllies.Text * 50.0)
decTtl += lblAlliesTtl.Text
End If
If cbWardaddy.Checked = True Then
lblWarTtl.Text = 0.0
decTtl += lblWarTtl.Text
End If
lblSubTotal.Text = String.Format("{0:C}", decTtl)
Dim decTxTtl = CDec(decTtl * 0.07)
lblTaxTtl.Text = String.Format("{0:C}", decTxTtl)
lblGrandTtl.Text = String.Format("{0:C}", (decTxTtl + decTtl))
End Function
Private Sub cbOil_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cbOil.CheckedChanged
processor()
End Sub
Private Sub cbAllies_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbAllies.CheckedChanged
processor()
End Sub
Private Sub cbWardaddy_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbWardaddy.CheckedChanged
processor()
End Sub
Mike_Mac
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
program uses a checkbox to acknowledge that that version of the ticket
is desired and it checks the Qty box to see how many tickets are
desired. Based upon the checkbox being checked and the number of tickets
desired directly affects the running grand total (of course!). OK I
have set where if ticketsDesiredTotal>0 then checkbox.checked = true.
The only problem I have is that if the user deletes the number of
tickets and the user does not enter a number and “ ” is in the tickets
desired box the program crashes. It crashes because it is taking the
value of TicketsDesiredTotal and multiplying it by the per ticket cost.
And the debugger says it can’t convert “” to use it in the equation.
How can I make this thing work??? Here is the code and the function it
calls:
Function processor()
Dim decTtl As Decimal = 0.0
Dim strOil As String = txtQtyOil.Text
If cbOil.Checked = True Then
lblOilTtl.Text = (txtQtyOil.Text * 150.0)
decTtl += lblOilTtl.Text
End If
If cbAllies.Checked = True Then
lblAlliesTtl.Text = (txtQtyAllies.Text * 50.0)
decTtl += lblAlliesTtl.Text
End If
If cbWardaddy.Checked = True Then
lblWarTtl.Text = 0.0
decTtl += lblWarTtl.Text
End If
lblSubTotal.Text = String.Format("{0:C}", decTtl)
Dim decTxTtl = CDec(decTtl * 0.07)
lblTaxTtl.Text = String.Format("{0:C}", decTxTtl)
lblGrandTtl.Text = String.Format("{0:C}", (decTxTtl + decTtl))
End Function
Private Sub cbOil_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles cbOil.CheckedChanged
processor()
End Sub
Private Sub cbAllies_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbAllies.CheckedChanged
processor()
End Sub
Private Sub cbWardaddy_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbWardaddy.CheckedChanged
processor()
End Sub
Mike_Mac
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!