Banking Project

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 5471 Views - Last Post: 09 March 2010 - 03:18 AM Rate Topic: -----

#1 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Banking Project

Posted 04 March 2010 - 06:45 PM

Hello Everyone, I'm sure you guys are getting sick of me lol. Again, I could use a little help . The program I am trying to build is supposed to compute your checking balance. Here's what I'm told to have on my form . (Create a project that will compute your checking balance, Form should incude radio buttons for deposit,check,and/or service charge.A text boxwillallow the user to enter the amount of the transaction. Display the new balance in a label Calculate the balance by adding deposits,and subtracting checks and charges. ) For some reason I have a calculation error. I would like someone to explain to me how I'm wrong.. At the very least show me where the wrong is. Please and thank you.

Here is my code.
 Dim mdecDeposit As Decimal = 100D
    Dim mdecCheck As Decimal = 50D
    Dim mdecServiceCharge As Decimal = 2.5D




    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'Terminate Project
        Me.Close()
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        'Clear all controls
        radDeposit.Checked = True
        radCheck.Checked = False
        radServiceCharge.Checked = False
        lblNewBalance.Text = ""
        With txtTransactions
            .Clear()
            .Focus()

        End With
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim decNewBalance As Decimal
        Dim StrMessage As String
        Dim decTransactions As Decimal
        Dim decDeposit As Decimal
        Dim decCheck As Decimal
        Dim decServiceCharge As Decimal


        If radDeposit.Checked Then
            decDeposit = mdecDeposit
        ElseIf radCheck.Checked Then
            decCheck = mdecCheck
        ElseIf radServiceCharge.Checked Then
            decServiceCharge = mdecServiceCharge
        Else
            MessageBox.Show("Please Make a transaction selection", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End If

        If txtTransactions.Text <> "" Then
            If IsNumeric(txtTransactions.Text) Then
                'Good data then preform transactions
                Try
                    decTransactions = CDec(txtTransactions.Text)
                    decNewBalance = decTransactions + mdecDeposit
                    decNewBalance = decTransactions - mdecCheck
                    decNewBalance = decTransactions - mdecServiceCharge

                    decNewBalance += decTransactions
                    lblNewBalance.Text = FormatCurrency(decNewBalance)
                    txtTransactions.Text = FormatCurrency(txtTransactions)
                Catch
                    StrMessage = "Calculation Error"
                    MessageBox.Show(StrMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try
            Else                 'Nonnumeric data
                StrMessage = "Nonnumeric data entered for transaction"
                MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtTransactions.Focus()
            End If
        Else
            StrMessage = "Enter money for a transaction"
            MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtTransactions.Focus()
        End If


    End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Banking Project

#2 Merddin  Icon User is offline

  • New D.I.C Head

Reputation: 12
  • View blog
  • Posts: 37
  • Joined: 19-February 10

Re: Banking Project

Posted 04 March 2010 - 07:46 PM

View PostFallenAngel, on 04 March 2010 - 05:45 PM, said:

For some reason I have a calculation error. I would like someone to explain to me how I'm wrong.. At the very least show me where the wrong is. Please and thank you.


Can you clarify what you mean by calculation error?
Was This Post Helpful? 0
  • +
  • -

#3 Searock  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 35
  • View blog
  • Posts: 259
  • Joined: 15-September 09

Re: Banking Project

Posted 05 March 2010 - 02:22 AM

have you posted the whole code?

Or can you tell me what are these three variables mdecDeposit, mdecCheck, mdecServiceCharge

try replacing the try catch with

Try
                    decTransactions = CDec(txtTransactions.Text)
                    decNewBalance = decTransactions + mdecDeposit
                    decNewBalance = decTransactions - mdecCheck
                    decNewBalance = decTransactions - mdecServiceCharge

                    decNewBalance += decTransactions
                    lblNewBalance.Text = FormatCurrency(decNewBalance)
                    txtTransactions.Text = FormatCurrency(txtTransactions)
                Catch ex As Exception
                    StrMessage = "Calculation Error"
                    MessageBox.Show(ex.Message & ". " & ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try




to find what is the exact error.

and I think your formulas are wrong (maybe).

This post has been edited by Searock: 05 March 2010 - 02:23 AM

Was This Post Helpful? 0
  • +
  • -

#4 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 06 March 2010 - 05:28 PM

View PostSearock, on 05 March 2010 - 01:22 AM, said:

have you posted the whole code?

Or can you tell me what are these three variables mdecDeposit, mdecCheck, mdecServiceCharge

try replacing the try catch with

Try
                    decTransactions = CDec(txtTransactions.Text)
                    decNewBalance = decTransactions + mdecDeposit
                    decNewBalance = decTransactions - mdecCheck
                    decNewBalance = decTransactions - mdecServiceCharge

                    decNewBalance += decTransactions
                    lblNewBalance.Text = FormatCurrency(decNewBalance)
                    txtTransactions.Text = FormatCurrency(txtTransactions)
                Catch ex As Exception
                    StrMessage = "Calculation Error"
                    MessageBox.Show(ex.Message & ". " & ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try




to find what is the exact error.

and I think your formulas are wrong (maybe).

You were righte I did have one part of my formula wrong,and it took me a while to find it.
I did finally get it working,but thank you both for trying to help me.
Was This Post Helpful? 0
  • +
  • -

#5 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 06 March 2010 - 06:12 PM

I'm being told to modify my Baking Project to display a message box if the new balance would be a negative number.
If there is not enough money to cover a check, do not deduct the check amount, Instead, display a message box with the message " Insufficient Funds" and deduct a service charge of 10.

Here is my code.

'Program :             Banking
'Programmer :          Pretty Princess
'Date       :          3/4/2010
'Description:          This program will add or subtract to your original balance


Option Strict On

Public Class frmBanking
    Dim mdecDeposit As Decimal = 100D
    Dim mdecCheck As Decimal = 50D
    Dim mdecServiceCharge As Decimal = 10D




    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'Terminate Project
        Me.Close()
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        'Clear all controls
        radDeposit.Checked = True
        radCheck.Checked = False
        radServiceCharge.Checked = False
        lblNewBalance.Text = ""
        With txtTransactions
            .Clear()
            .Focus()

        End With
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim decNewBalance As Decimal
        Dim StrMessage As String
        Dim decTransactions As Decimal
        Dim decDeposit As Decimal
        Dim decCheck As Decimal
        Dim decServiceCharge As Decimal


        If radDeposit.Checked Then
            decDeposit = mdecDeposit
        ElseIf radCheck.Checked Then
            decCheck = mdecCheck
        ElseIf radServiceCharge.Checked Then
            decServiceCharge = mdecServiceCharge
        Else
            MessageBox.Show("Please Make a transaction selection", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

        If txtTransactions.Text <> "" Then
            If IsNumeric(txtTransactions.Text) Then
                'Good data then preform transactions
                Try
                    decTransactions = CDec(txtTransactions.Text)
                    If radDeposit.Checked Then
                        decNewBalance = decTransactions + mdecDeposit
                    ElseIf radCheck.Checked Then
                        decNewBalance = decTransactions - mdecCheck - mdecServiceCharge   'Not right. Shouldn't deduct check. 
                    ElseIf radServiceCharge.Checked Then 
                        decNewBalance = decTransactions - mdecServiceCharge
                    
                    End If
                  
                    decTransactions += decNewBalance
                    lblNewBalance.Text = FormatCurrency(decNewBalance)

                Catch
                    StrMessage = "Calculation Error"
                    MessageBox.Show(StrMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try
            Else                 'Nonnumeric data
                StrMessage = "Nonnumeric data entered for transaction"
                MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtTransactions.Focus()
            End If
        Else
            StrMessage = "Enter money for a transaction"
            MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtTransactions.Focus()
        End If


    End Sub
End Class



What I don't understand is how I would make it a negative number and deduct the service charge of 10 without deducting the check. Could someone please explain this too me?

This post has been edited by FallenAngel: 07 March 2010 - 02:06 AM

Was This Post Helpful? 0
  • +
  • -

#6 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Banking Project

Posted 06 March 2010 - 08:14 PM

Ignore this post, I thought I had started a new topic and originally posted it here :stupid:

This post has been edited by CharlieMay: 06 March 2010 - 08:17 PM

Was This Post Helpful? 0
  • +
  • -

#7 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 06 March 2010 - 08:42 PM

I have Modified my code with what I think should be the correct code,but my message box still isn't showing

'Program :             Banking
'Programmer :          Pretty Princess
'Date       :          3/4/2010
'Description:          This program will add or subtract to your original balance


Option Strict On

Public Class frmBanking
    Dim mdecDeposit As Decimal = 100D
    Dim mdecCheck As Decimal = 50D
    Dim mdecServiceCharge As Decimal = 10D




    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'Terminate Project
        Me.Close()
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        'Clear all controls
        radDeposit.Checked = True
        radCheck.Checked = False
        radServiceCharge.Checked = False
        lblNewBalance.Text = ""
        With txtTransactions
            .Clear()
            .Focus()

        End With
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim decNewBalance As Decimal
        Dim StrMessage As String
        Dim decTransactions As Decimal
        Dim decDeposit As Decimal
        Dim decCheck As Decimal
        Dim decServiceCharge As Decimal


        If radDeposit.Checked Then
            decDeposit = mdecDeposit
        ElseIf radCheck.Checked Then
            decCheck = mdecCheck
        ElseIf radServiceCharge.Checked Then
            decServiceCharge = mdecServiceCharge
        Else
            MessageBox.Show("Please Make a transaction selection", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

        If txtTransactions.Text <> "" Then
            If IsNumeric(txtTransactions.Text) Then
                'Good data then preform transactions
                Try
                    '//decTransactions = CDec(txtTransactions.Text) ' I had this commented out because I thought I didn't need it. Turns out I do. Even with my other if statement
                    If radDeposit.Checked Then
                        decNewBalance = decTransactions + mdecDeposit
                    ElseIf radCheck.Checked Then
                        If CDec(txtTransactions.Text) < 50 Then     ,// What I'm trying to do is get the message box to show
                                                                        '//by putting in a number less then 50 it should pop up
                                                                        '//saying insufficient funds.Is that right?       
                            decNewBalance = decTransactions - mdecServiceCharge
                        ElseIf radServiceCharge.Checked Then
                            decNewBalance = decTransactions - decServiceCharge
                        Else
                            MessageBox.Show("Insufficient Funds", "Not enough money", MessageBoxButtons.OK,  MessageBoxIcon.Information)  '// <~~~~ I'm almost enclined to believe that this is in the wrong place,or code is wrong.
                        End If
                        decNewBalance = decTransactions - mdecServiceCharge

                    End If

                    decTransactions += decNewBalance
                    lblNewBalance.Text = FormatCurrency(decNewBalance)

                Catch
                    StrMessage = "Calculation Error"
                    MessageBox.Show(StrMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try
            Else                 'Nonnumeric data
                StrMessage = "Nonnumeric data entered for transaction"
                MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtTransactions.Focus()
            End If
        Else
            StrMessage = "Enter money for a transaction"
            MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtTransactions.Focus()
        End If


    End Sub
End Class


This post has been edited by FallenAngel: 07 March 2010 - 02:12 AM

Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: Banking Project

Posted 06 March 2010 - 08:49 PM

Why did you open a NEW TOPIC on the same problem/code?

Merged topics.
Was This Post Helpful? 0
  • +
  • -

#9 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 06 March 2010 - 09:22 PM

Thank You Jack, I'm sorry to have opened a new one..
Was This Post Helpful? 0
  • +
  • -

#10 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 07 March 2010 - 04:13 AM

View PostFallenAngel, on 06 March 2010 - 07:42 PM, said:

I have Modified my code with what I think should be the correct code,but my message box still isn't showing

'Program :             Banking
'Programmer :          Pretty Princess
'Date       :          3/4/2010
'Description:          This program will add or subtract to your original balance


Option Strict On

Public Class frmBanking
    Dim mdecDeposit As Decimal = 100D
    Dim mdecCheck As Decimal = 50D
    Dim mdecServiceCharge As Decimal = 10D




    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        'Terminate Project
        Me.Close()
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        'Clear all controls
        radDeposit.Checked = True
        radCheck.Checked = False
        radServiceCharge.Checked = False
        lblNewBalance.Text = ""
        With txtTransactions
            .Clear()
            .Focus()

        End With
    End Sub

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim decNewBalance As Decimal
        Dim StrMessage As String
        Dim decTransactions As Decimal
        Dim decDeposit As Decimal
        Dim decCheck As Decimal
        Dim decServiceCharge As Decimal


        If radDeposit.Checked Then
            decDeposit = mdecDeposit
        ElseIf radCheck.Checked Then
            decCheck = mdecCheck
        ElseIf radServiceCharge.Checked Then
            decServiceCharge = mdecServiceCharge
        Else
            MessageBox.Show("Please Make a transaction selection", "Selection Required", MessageBoxButtons.OK, MessageBoxIcon.Information)

        End If

        If txtTransactions.Text <> "" Then
            If IsNumeric(txtTransactions.Text) Then
                'Good data then preform transactions
                Try
                    '//decTransactions = CDec(txtTransactions.Text) ' I had this commented out because I thought I didn't need it. Turns out I do. Even with my other if statement
                    If radDeposit.Checked Then
                        decNewBalance = decTransactions + mdecDeposit
                    ElseIf radCheck.Checked Then
                        If CDec(txtTransactions.Text) < 50 Then     ,// What I'm trying to do is get the message box to show
                                                                        '//by putting in a number less then 50 it should pop up
                                                                        '//saying insufficient funds.Is that right?       
                            decNewBalance = decTransactions - mdecServiceCharge
                        ElseIf radServiceCharge.Checked Then
                            decNewBalance = decTransactions - decServiceCharge
                        Else
                            MessageBox.Show("Insufficient Funds", "Not enough money", MessageBoxButtons.OK,  MessageBoxIcon.Information)  '// <~~~~ I'm almost enclined to believe that this is in the wrong place,or code is wrong.
                        End If
                        decNewBalance = decTransactions - mdecServiceCharge

                    End If

                    decTransactions += decNewBalance
                    lblNewBalance.Text = FormatCurrency(decNewBalance)

                Catch
                    StrMessage = "Calculation Error"
                    MessageBox.Show(StrMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try
            Else                 'Nonnumeric data
                StrMessage = "Nonnumeric data entered for transaction"
                MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                txtTransactions.Focus()
            End If
        Else
            StrMessage = "Enter money for a transaction"
            MessageBox.Show(StrMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
            txtTransactions.Focus()
        End If


    End Sub
End Class


I have got my service charge part way working.. It will pop a message box saying insuffcient funds,but will not charge a 10 dollar service charge.
I've stepped into my code and see that it is complelty missing to charge the 10 dollars,but can't figure out why.
Was This Post Helpful? 0
  • +
  • -

#11 Guest_FallenAngel*


Reputation:

Re: Banking Project

Posted 09 March 2010 - 12:10 AM

I'm really not seeing what is wrong with this my project..
Someone please help me. It's probably small,but I've tried everything I can think of from catanations, to doing it through the checkbox itself,but
either just the messagebox pops up,or it just adds the 10 dollar fee. How do you combine the two?
Was This Post Helpful? 0

#12 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: Banking Project

Posted 09 March 2010 - 02:01 AM

Hi,

I would first of all get rid of the ElseIf statements since they can cause confusion if not properly used.
rather use normal if statements, it helps to clarify. (In my 10 years of programming i never had to use ElseIf)

Next, i would get rid of the try catch.

If you use try catch, then at least try and catch something you know you can handle (meaning the error).

Like this FOR INVALID CAST

 Try

 Catch ex As InvalidCastException

 End Try



This would be catching on all errrors.... and you should try and avoid it. If you know an error will happen, handle it correctly.

 Try

 Catch 

 End Try



Finally, comment out most of your code and try from the beginning, see where do things work and if they don't correct them then start with the next bit of code.
Was This Post Helpful? 1
  • +
  • -

#13 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 09 March 2010 - 02:19 AM

Motcom, Thank you soo much for your reply.
I do know what's not working on my code and what is.
I just don't know how to make it work. That is what is stressing me out.


View Postmotcom, on 09 March 2010 - 08:01 AM, said:

Hi,

I would first of all get rid of the ElseIf statements since they can cause confusion if not properly used.
rather use normal if statements, it helps to clarify. (In my 10 years of programming i never had to use ElseIf)

Next, i would get rid of the try catch.

If you use try catch, then at least try and catch something you know you can handle (meaning the error).

Like this FOR INVALID CAST

 Try

 Catch ex As InvalidCastException

 End Try



This would be catching on all errrors.... and you should try and avoid it. If you know an error will happen, handle it correctly.

 Try

 Catch 

 End Try



Finally, comment out most of your code and try from the beginning, see where do things work and if they don't correct them then start with the next bit of code.

Was This Post Helpful? 0
  • +
  • -

#14 motcom  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 290
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: Banking Project

Posted 09 March 2010 - 02:45 AM

Hey, you will have to start somewhere, so the best way is to understand where the error (be it calculation or runtime error) is. So go to the beginning, maybe make another form and add the items bit by bit, you will soon enough find where there is a problem...
Was This Post Helpful? 0
  • +
  • -

#15 FallenAngel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 24-February 10

Re: Banking Project

Posted 09 March 2010 - 03:01 AM

I DID IT!!!!!!

RUNS AROUND SCREAMING AND HANDING EVERYONE THEIR FAVORITE CANDY..!!!!!!!

If you don't like candy name something you like and I'll give it to you.. !!!!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2