Homework Problem?? *RESOLVED*
Here is what I have to build:
Checking Account
I am stuck on my Withdrawal values and Balance. I think I can figure out Balance if I can get my Withdrawals to work correct. Withdrawals is just the Transaction Amount when radio button Check is checked. I have it represented as WT = WT + TA.
My problem is TA is retaining it's value everytime I click anything. I have it as TA = Val(txtTransaction.Text).
When I type 300 in TA and have the radio Deposit checked, then everything works fine. My txtDeposits.Text displays right and so does txtBalance.Text, but when I click Next and reset TA, and check radio Check, then somehow it it using the value I entered before and then calculating Withdrawals. I think it might be the way I have set up the variables but really don't know. This is the code I have:
VB Code:
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