Kal-El2K8
2011-07-13 17:30:44 UTC
Private Sub SummaryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryToolStripMenuItem.Click
'Declare Variables
Const SERVICE_CHARGE As Decimal = 10.0
Dim TotalDeposits, TotalChecks, AccountBalance As Decimal
Dim Number_Of_Deposits, Number_Of_Checks As Integer
Dim MessageString As String
'Calculate
AccountBalance = Decimal.Parse(EnterAmountTextBox.Text)
If DepositRadioButton.Checked Then
TotalDeposits = (TotalDeposits + AccountBalance)
Number_Of_Deposits = (Number_Of_Deposits + 1)
ElseIf CheckRadioButton.Checked And AccountBalance > 0 Then
TotalChecks = (TotalChecks + AccountBalance)
Number_Of_Checks = (Number_Of_Checks + 1)
End If
If CheckRadioButton.Checked And AccountBalance < 0 Then
AccountBalance = (AccountBalance - SERVICE_CHARGE)
End If
MessageString = "Total Number of Deposits: " _
& Number_Of_Deposits.ToString() _
& Environment.NewLine & Environment.NewLine _
& "Total Amount of Deposits: " _
& TotalDeposits.ToString("c") _
& Environment.NewLine & Environment.NewLine _
& "Total Number of Checks: " _
& Number_Of_Checks.ToString() _
& Environment.NewLine & Environment.NewLine _
& "Total Amount of Checks: " _
& TotalChecks.ToString("c")
MessageBox.Show(MessageString, "Account Summary", MessageBoxButtons.OK, MessageBoxIcon.None)
End Sub
Private Sub TransactionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TransactionToolStripMenuItem.Click
'Declare Variables
Dim EnterAmount, AccountBalance As Decimal
Const SERVICE_CHARGE As Decimal = 10.0
'Calculate
EnterAmount = Decimal.Parse(EnterAmountTextBox.Text)
'Determine if the amount entered is to be added or subtracted
If DepositRadioButton.Checked Then
AccountBalanceTextBox.Text = (AccountBalance + EnterAmount).ToString("c")
ElseIf CheckRadioButton.Checked Then
AccountBalanceTextBox.Text = (AccountBalance - EnterAmount).ToString("c")
ElseIf ServiceChargeRadioButton.Checked Then
AccountBalanceTextBox.Text = (AccountBalance - SERVICE_CHARGE).ToString("c")
End If
'Display a message box if there are insufficient funds in the account
If CheckRadioButton.Checked = True Then
If EnterAmount > AccountBalance Then
MessageBox.Show("Insufficient Funds: $10.00 Service Charge!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
AccountBalanceTextBox.Text = (AccountBalance - SERVICE_CHARGE).ToString("c")
End If
End If
'Display a message box if the amount entered is a negative number
If EnterAmount < 0 Then
MessageBox.Show("Please enter an amount greater than zero!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
End Sub