Name: Anonymous 2007-12-05 23:11
Dim strTextBox As String
Dim decItemPrice As Decimal
Dim decSubTotal As Decimal
Dim intNumber As Integer
Dim decSalesTax As Decimal
Dim decTotalSale As Decimal
Do
strTextBox = InputBox("Enter item price", "Item Price")
If Decimal.TryParse(strTextBox, decItemPrice) Then
decItemPrice = Convert.ToDecimal(strTextBox)
decSubTotal = decItemPrice
intNumber = intNumber + 1
txtItemPrice.Text = FormatCurrency(decItemPrice)
txtSubTotal.Text = FormatCurrency(decSubTotal)
txtNumber.Text = Convert.ToString(intNumber)
End If
Loop Until strTextBox = ""
decSalesTax = 0.065D * decSubTotal
decTotalSale = decSubTotal + decSalesTax
txtSalesTax.Text = FormatCurrency(decSalesTax)
txtTotalSale.Text = FormatCurrency(decTotalSale)
End Sub
I need help doing two things: 1) Making sure only numerical data can be entered or else a message box is displayed. 2) Keep a running Sub Total so that the first entered number is added to the second entered and so on until the loop is terminated.
Dim decItemPrice As Decimal
Dim decSubTotal As Decimal
Dim intNumber As Integer
Dim decSalesTax As Decimal
Dim decTotalSale As Decimal
Do
strTextBox = InputBox("Enter item price", "Item Price")
If Decimal.TryParse(strTextBox, decItemPrice) Then
decItemPrice = Convert.ToDecimal(strTextBox)
decSubTotal = decItemPrice
intNumber = intNumber + 1
txtItemPrice.Text = FormatCurrency(decItemPrice)
txtSubTotal.Text = FormatCurrency(decSubTotal)
txtNumber.Text = Convert.ToString(intNumber)
End If
Loop Until strTextBox = ""
decSalesTax = 0.065D * decSubTotal
decTotalSale = decSubTotal + decSalesTax
txtSalesTax.Text = FormatCurrency(decSalesTax)
txtTotalSale.Text = FormatCurrency(decTotalSale)
End Sub
I need help doing two things: 1) Making sure only numerical data can be entered or else a message box is displayed. 2) Keep a running Sub Total so that the first entered number is added to the second entered and so on until the loop is terminated.