Option Strict On
Public Class Form1
Inherits System.Windows.Forms.Form
' Assignment 3: Checking Account
' Programmer: Brad von Oven
' Date: June 12, 2004
' Purpose: Create an application to display a checkbook.
' The user enters a transaction amount in a text
' box and selects a button for deposit or check.
' An update button performs validation on the text
' box to make sure there is a number greater
' than 0 in the box. If the entry is not OK then
' use a message box to tell the user and reset the
' focus back to the text box and stop the sub
' procedure. When the entry is acceptable the
' update button evaluates the transaction and
' adds deposits while subtracting checks from the
' balance. If the check is greater than the
' balance a service charge of $25 is applied
' instead of the check amount. Keep track of the
' balance, total amount in dollars of checks,
' deposits and service charges. Display the
' results. Option strict is on.
' Declare variables and constants
Dim TA, BL, WT, CH, DP, DX As Double
Const CA As Double = 25
' TA is txtTransaction
' BL is txtBalance
' WT is txtWithdrawals
' CH is txtCharges
' DP is txtDeposits
' CA is Charge Amount
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
txtTransaction.Text = ""
txtTransaction.Focus()
End Sub
Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
TA = Val(txtTransaction.Text)
DP = DP + TA
DX = DP
WT = WT + TA
CH = CH + CA
BL = ((DX - TA) - WT)
If txtTransaction.Text <= "0" Then
MessageBox.Show("Please enter an amount > 0.", "Error")
txtTransaction.Focus()
End If
If radDeposit.Checked Then
txtDeposits.Text = (DP).ToString("c")
txtBalance.Text = (DP).ToString("c")
End If
If radCheck.Checked Then
txtWithdrawals.Text = (WT).ToString("c")
txtBalance.Text = (BL).ToString("c")
End If
End Sub
End Class