Results 1 to 11 of 11

Thread: Homework Problem?? *RESOLVED*

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2004
    Posts
    131

    Question 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:
    1. Option Strict On
    2. Public Class Form1
    3.     Inherits System.Windows.Forms.Form
    4.  
    5.     ' Assignment 3:     Checking Account
    6.     ' Programmer:       Brad von Oven
    7.     ' Date:             June 12, 2004
    8.     ' Purpose:          Create an application to display a checkbook.  
    9.     '                   The user enters a transaction amount in a text
    10.     '                   box and selects a button for deposit or check.  
    11.     '                   An update button performs validation on the text
    12.     '                   box to make sure there is a number greater
    13.     '                   than 0 in the box.  If the entry is not OK then
    14.     '                   use a message box to tell the user and reset the
    15.     '                   focus back to the text box and stop the sub
    16.     '                   procedure.  When the entry is acceptable the
    17.     '                   update button evaluates the transaction and
    18.     '                   adds deposits while subtracting checks from the
    19.     '                   balance.  If the check is greater than the
    20.     '                   balance a service charge of $25 is applied
    21.     '                   instead of the check amount.  Keep track of the
    22.     '                   balance, total amount in dollars of checks,
    23.     '                   deposits and service charges.  Display the
    24.     '                   results.  Option strict is on.
    25.  
    26.     ' Declare variables and constants
    27.     Dim TA, BL, WT, CH, DP, DX As Double
    28.     Const CA As Double = 25
    29.     ' TA is txtTransaction
    30.     ' BL is txtBalance
    31.     ' WT is txtWithdrawals
    32.     ' CH is txtCharges
    33.     ' DP is txtDeposits
    34.     ' CA is Charge Amount
    35.  
    36.  
    37.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    38.  
    39.     End Sub
    40.  
    41.     Private Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
    42.         txtTransaction.Text = ""
    43.         txtTransaction.Focus()
    44.     End Sub
    45.  
    46.     Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
    47.         TA = Val(txtTransaction.Text)
    48.         DP = DP + TA
    49.         DX = DP
    50.         WT = WT + TA
    51.         CH = CH + CA
    52.         BL = ((DX - TA) - WT)
    53.        
    54.         If txtTransaction.Text <= "0" Then
    55.             MessageBox.Show("Please enter an amount > 0.", "Error")
    56.             txtTransaction.Focus()
    57.         End If
    58.  
    59.  
    60.         If radDeposit.Checked Then
    61.             txtDeposits.Text = (DP).ToString("c")
    62.             txtBalance.Text = (DP).ToString("c")
    63.  
    64.         End If
    65.        
    66.         If radCheck.Checked Then
    67.             txtWithdrawals.Text = (WT).ToString("c")
    68.             txtBalance.Text = (BL).ToString("c")
    69.         End If
    70.  
    71.     End Sub
    72. End Class
    Last edited by twisted; Jun 14th, 2004 at 01:09 PM.
    Twisted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width