Graciemygirl
New member
- Joined
- Apr 14, 2013
- Messages
- 1
- Programming Experience
- 1-3
Just learning VB and I got this far...all functions work but a requirement is to have "0"s in the text and Label boxes upon clearing the form...I cannot get it to work correctly, any help would be appreciated!
Public Class Form1 Private Sub btnCalculateTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateTotal.Click 'Declare Varibles for calculations Dim decCalculatedTotalTax As Decimal 'Total Tax Owed Dim decCountyTax1 As Decimal 'County Tax Owed Dim decStateSalesTax1 As Decimal 'Total Tax Owed Const decCountyTax_Rate As Decimal = 0.02D 'County Tax Rate Const decStateSalesTax_Rate As Decimal = 0.04D 'State Tax Rate Try 'Calculate County Tax and Display decCountyTax1 = CDec(txtTotalSales.Text) * decCountyTax_Rate lblCountyTax1.Text = decCountyTax1.ToString("c") 'Calculate State Tax and Display decStateSalesTax1 = CDec(txtTotalSales.Text) * decStateSalesTax_Rate lblStateSalesTax1.Text = decStateSalesTax1.ToString("c") 'Calculate Total Tax Owed decCalculatedTotalTax = decStateSalesTax1 + decCountyTax1 lblCalculatedTotalTax.Text = decCalculatedTotalTax.ToString("c") Catch 'Error Message MessageBox.Show("Correct Total Sales Amount...Must Be A Dollar Amount.") End Try End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click 'Clear all fields on the form and set the cursor back at the top lblCountyTax1.Text = String.Empty 'Alternate technique to clear txtTotalSales.Clear() lblCountyTax1.Text = String.Empty lblStateSalesTax1.Text = String.Empty lblCalculatedTotalTax.Text = String.Empty 'Sets Cursor Back at top in Enter Total Sales txtTotalSales.Focus() End Sub Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click 'Close the Form Me.Close() End Sub End Class
Last edited by a moderator: