Create a project in VB (using Option Strict ON) to calculate a checking account
ID: 3663497 • Letter: C
Question
Create a project in VB (using Option Strict ON) to calculate a checking account balance. Include radio buttons to indicate the type of transaction: deposit, check or service charge. A text box will allow the user to enter the amount of the transaction. Display a new balance in a ReadOnly text box. Calculate the balance by adding deposits and subtracting service charges and checks. Include buttons for calculate, clear, print, and exit. I'm having trouble with the coding aspect for the calculation button and showing the correct amount in the new balance window using Option Strict On. The actual design, elements, and clear/print/exit buttons are already complete.
Explanation / Answer
Option Strict On
Option Explicit On
PublicClassCheckingAccountForm
'Declare Module variables.
Private DepositDecimal, CheckDecimal AsDecimal
Private DepositCounterInteger, CheckCounterInteger AsInteger
Const SERVICE_CHARGE_Decimal AsDecimal = 10D
Private BalDecimal, TotalServChgDecimal, ServChgDecimal, TotalDepositDecimal, TotalCheckDecimal AsDecimal
PrivateSub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
'Print the form to preview.
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
EndSub
PrivateSub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
'Close the program
Me.Close()
EndSub
PrivateSub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
'Clear the transactions.
AmtofTransTextBox.Clear()
EndSub
PrivateSub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
'Declare the variables.
Dim AmtTransDecimal AsDecimal
Try'Calculate to find the Deposit - Check - Service Chg for Balance
AmtTransDecimal = Decimal.Parse(AmtofTransTextBox.Text)
If DepositRadioButton.Checked Then
DepositDecimal = AmtTransDecimal
BalDecimal += DepositDecimal
TotalDepositDecimal += DepositDecimal
NewBalanceTextBox.Text = BalDecimal.ToString("C")
DepositCounterInteger += 1
EndIf
If CheckRadioButton.Checked Then
CheckDecimal = AmtTransDecimal
EndIf
If BalDecimal < AmtTransDecimal Then
MessageBox.Show("Insuffencient Funds")
BalDecimal -= SERVICE_CHARGE_Decimal
TotalServChgDecimal += ServChgDecimal
CheckDecimal -= AmtTransDecimal
NewBalanceTextBox.Text = BalDecimal.ToString()
AmtTransDecimal = Decimal.Parse(AmtofTransTextBox.Text)
CheckCounterInteger += 1
EndIf
If ServiceChargeRadioButton.Checked Then
TotalServChgDecimal -= AmtTransDecimal
EndIf
Catch AmtTransDecimalException AsFormatException
If ServiceChargeRadioButton.Checked Then
ServChgDecimal = AmtTransDecimal
BalDecimal += ServChgDecimal
NewBalanceTextBox.Text = BalDecimal.ToString()
EndIf
EndTry
EndSub
PrivateSub SummaryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryButton.Click
'Declare the variables
Dim TotalNumberDepositCountInteger, TotalNumberCheckCountInteger AsInteger
Dim MessageString AsString
'Display the Summary Messages.
MessageString = "Number of Deposits: " & TotalNumberDepositCountInteger.ToString() &
Environment.NewLine & "Total Deposit Amount: " & TotalDepositDecimal.ToString("C") &
Environment.NewLine & "Number of Checks: " & TotalNumberCheckCountInteger.ToString() &
Environment.NewLine & "Total Check Amount: " & TotalCheckDecimal.ToString("C") &
Environment.NewLine & "Service Charges: " & TotalServChgDecimal.ToString("C")
'Display the message box
MessageBox.Show(MessageString, "Your Account Summary", MessageBoxButtons.OK, MessageBoxIcon.Information)
EndSub
EndClass
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.