GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Oct-2009, 00:21
jamesgreen44 jamesgreen44 is offline
New Member
 
Join Date: Oct 2009
Location: Montana
Posts: 2
jamesgreen44 is an unknown quantity at this point

Understanding function procedures


I am learning Visual Basic 2008, and I am having a hard time understanding function procedures. Can someone help me write a function procedure for the transaction?

VB / Visual Basic Code:
Public Class Form1
    'Declare module-level variables for summary information.
    Private TotalNumberDepositsCountInteger, TotalNumberChecksCountInteger, TotalServiceChargeInteger As Integer
    Private TotalDollarAmountDepositsDecimal, TotalDollarAmountChecksDecimal, AccountBalanceDecimal, AmountDecimal, TotalAmountServiceChargeDecimal As Decimal
    'Declare module-level constants.
    Const SERVICE_CHARGE_Decimal As Decimal = 10D
    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        'Terminate the project.
        Me.Close()
    End Sub

    Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
        'Prints the form.
        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()
    End Sub

    Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
        'Calculate the balance by adding deposits, and subtracting service charges and checks.
        Dim AmountDecimal As Decimal
        Try
            If Decimal.Parse(EnterAmountTextBox.Text) > 0 Then
                'assigns the variable
                AmountDecimal = Decimal.Parse(EnterAmountTextBox.Text)


                'checks to see which radio button is checked and performs calculations.
                If DepositRadioButton.Checked Then
                    AccountBalanceDecimal += AmountDecimal
                    TotalDollarAmountDepositsDecimal += AmountDecimal
                    TotalNumberDepositsCountInteger += 1
                ElseIf CheckRadioButton.Checked Then
                    'checks to see if balance is greater than the amount entered.
                    If AccountBalanceDecimal >= AmountDecimal Then
                        AccountBalanceDecimal -= AmountDecimal
                        TotalNumberChecksCountInteger += 1
                        TotalDollarAmountChecksDecimal += AmountDecimal

                        'If amount entetered is more than the balance, then give an error, and deduct $10.00 from balance.
                    Else
                        MessageBox.Show("Insufficient Funds")
                        AccountBalanceDecimal -= SERVICE_CHARGE_Decimal
                        TotalDollarAmountChecksDecimal += SERVICE_CHARGE_Decimal
                        TotalServiceChargeInteger += 1
                    End If

                ElseIf ServiceChargeRadioButton.Checked Then
                    AccountBalanceDecimal -= AmountDecimal
                    TotalAmountServiceChargeDecimal += AmountDecimal
                    TotalServiceChargeInteger += 1

                    'If no radio button is selected thengive an error.
                Else
                    MessageBox.Show("You must select either Deposit, Checking, or Service Charge" _
                                    , "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End If

                'Displays the final total in textbox
                AccountBalanceTextBox.Text = AccountBalanceDecimal.ToString("C")

                'If numeric values are not entered, then give an error.
            Else
                MessageBox.Show("You cannot enter negative numbers into the ammount textbox." _
                                , "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End If

        Catch
            MessageBox.Show("You must enter numbers into the ammount textbox", "Invalid Input" _
                            , MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
        'Clear the appropriate controls
        AccountBalanceTextBox.Clear()
        With EnterAmountTextBox
            .Clear()
            .Focus()
        End With
        DepositRadioButton.Checked = False
        CheckRadioButton.Checked = False
        ServiceChargeRadioButton.Checked = False
    End Sub

    Private Sub SummaryButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryButton.Click
        'Display Summary Information.
        Dim MessageString As String
        'Concatenate the message string
        MessageString = "Total Deposits:  " _
            & TotalNumberDepositsCountInteger.ToString() _
            & Environment.NewLine & Environment.NewLine _
            & "Total Amount of Deposits:  " & TotalDollarAmountDepositsDecimal.ToString("C") _
            & Environment.NewLine & Environment.NewLine _
            & "TotalChecks:  " & TotalNumberChecksCountInteger.ToString() _
            & Environment.NewLine & Environment.NewLine _
            & "Total Amount of Checks:  " & TotalDollarAmountChecksDecimal.ToString("C") _
            & Environment.NewLine & Environment.NewLine _
            & "Total Service Charges:  " & TotalServiceChargeInteger.ToString() _
            & Environment.NewLine & Environment.NewLine _
            & "Total Amount of Service Charges:  " & TotalAmountServiceChargeDecimal.ToString("C")
        MessageBox.Show(MessageString, "Checking Account Summary", _
        MessageBoxButtons.OK, MessageBoxIcon.Information)





    End Sub

End Class
Last edited by admin : 08-Oct-2009 at 00:37. Reason: Please insert your example VB codes between [VB] and [/VB] tags
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
run script command on ns2.26 newbie06 Computer Software Forum - Linux 65 19-Aug-2009 08:50
Problem executing nam-1.13 RodolfoAlvizu Computer Software Forum - Linux 20 28-Feb-2009 16:23
Flex and bison coding lucky88star C++ Forum 5 24-Dec-2007 12:57
Need Help with input files. Efferus C++ Forum 2 24-Nov-2007 17:19
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:35.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.