Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Summary problem

Summary problem

Scheduled Pinned Locked Moved Visual Basic
questionrubyhelp
7 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RubyM
    wrote on last edited by
    #1

    I am currently enrolled in a VB class and am completely new to the class and this forum so if you need any additional information please let me know. I hope this question makes sense to someone. lol My current project requires me to do a summary with a running total of the number of deposits, amount of deposit, number of checks, amount of checks etc. I am able to get the summary up in a new messagebox but it will only show the last transaction. for instance if I make a deposit, then write a check, the summary will only show the check written and the amount of the check. It will not show the deposit I made or the amount of the deposit. How can I get it to show all of the totals from all of the transactions? If you need any code I can provide it for you. Thanks, Ruby

    C 1 Reply Last reply
    0
    • R RubyM

      I am currently enrolled in a VB class and am completely new to the class and this forum so if you need any additional information please let me know. I hope this question makes sense to someone. lol My current project requires me to do a summary with a running total of the number of deposits, amount of deposit, number of checks, amount of checks etc. I am able to get the summary up in a new messagebox but it will only show the last transaction. for instance if I make a deposit, then write a check, the summary will only show the check written and the amount of the check. It will not show the deposit I made or the amount of the deposit. How can I get it to show all of the totals from all of the transactions? If you need any code I can provide it for you. Thanks, Ruby

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You need to show the code.  The answer is, pass all the info you want to see, into the messagebox.

      Christian Graus - C++ MVP

      R 1 Reply Last reply
      0
      • C Christian Graus

        You need to show the code.  The answer is, pass all the info you want to see, into the messagebox.

        Christian Graus - C++ MVP

        R Offline
        R Offline
        RubyM
        wrote on last edited by
        #3

        ok, here is the code: Public Class CheckingAccount Dim Service = "10.00" Dim enterAmount As Decimal Dim Balance As Decimal Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Private Sub menTransaction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menTransaction.Click With Me enterAmount = Decimal.Parse(txtAmount.Text) If butDeposit.Checked = True Then Balance = Balance + enterAmount totalNumOfDeposit = totalNumOfDeposit + 1 totalAmtOfDeposits = totalAmtOfDeposits + enterAmount ElseIf butCheck.Checked = True Then Balance = Balance - enterAmount totalChecks = totalChecks + 1 totalAmountOfChecks = totalAmountOfChecks + enterAmount ElseIf butService.Checked = True Then Balance = Balance - Service totalAmountOfService = totalamountOfChecks + Service End If Me.txtBalance.Text = Balance.ToString("C") Me.txtAmount.Clear() Me.txtAmount.Focus() End With End Sub Private Sub menSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menSummary.Click Dim Service As Decimal = "10.00" Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Dim messageString As String With Me If butDeposit.Checked = True Then totalNumOfDeposit = totalNumOfDeposit + 1 totalAmtOfDeposits = totalAmtOfDeposits + enterAmount ElseIf butCheck.Checked = True Then totalChecks = totalChecks + 1 totalAmountOfChecks = totalAmountOfChecks + enterAmount ElseIf butService.Checked = True Then totalAmountOfService = totalAmountOfService + Service End If messageString = "Total Deposits: " _ & totalNumOfDeposit.ToString() _ & ControlChars.NewLine _ & "Total Amount Of Deposits: " & totalAmtOfDeposits.ToString() _ & ControlChars.NewLine _ & "Total Checks: " & totalChecks.ToStri

        C 1 Reply Last reply
        0
        • R RubyM

          ok, here is the code: Public Class CheckingAccount Dim Service = "10.00" Dim enterAmount As Decimal Dim Balance As Decimal Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Private Sub menTransaction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menTransaction.Click With Me enterAmount = Decimal.Parse(txtAmount.Text) If butDeposit.Checked = True Then Balance = Balance + enterAmount totalNumOfDeposit = totalNumOfDeposit + 1 totalAmtOfDeposits = totalAmtOfDeposits + enterAmount ElseIf butCheck.Checked = True Then Balance = Balance - enterAmount totalChecks = totalChecks + 1 totalAmountOfChecks = totalAmountOfChecks + enterAmount ElseIf butService.Checked = True Then Balance = Balance - Service totalAmountOfService = totalamountOfChecks + Service End If Me.txtBalance.Text = Balance.ToString("C") Me.txtAmount.Clear() Me.txtAmount.Focus() End With End Sub Private Sub menSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menSummary.Click Dim Service As Decimal = "10.00" Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Dim messageString As String With Me If butDeposit.Checked = True Then totalNumOfDeposit = totalNumOfDeposit + 1 totalAmtOfDeposits = totalAmtOfDeposits + enterAmount ElseIf butCheck.Checked = True Then totalChecks = totalChecks + 1 totalAmountOfChecks = totalAmountOfChecks + enterAmount ElseIf butService.Checked = True Then totalAmountOfService = totalAmountOfService + Service End If messageString = "Total Deposits: " _ & totalNumOfDeposit.ToString() _ & ControlChars.NewLine _ & "Total Amount Of Deposits: " & totalAmtOfDeposits.ToString() _ & ControlChars.NewLine _ & "Total Checks: " & totalChecks.ToStri

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          RubyM wrote:

          Dim Service As Decimal = "10.00" Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Dim messageString As String

          People used to do this in C, because they had to.  You should declare variables as you use them. So you're saying this message box doesn't show all of the messageString ? Does it show the constants you're passing in ?

          RubyM wrote:

          totalAmountOfChecks.ToString()

          I don't believe you need to call ToString, it works it out. Have you stepped through the debugger to see what's happening ?

          RubyM wrote:

          enterAmount = Decimal.Parse(txtAmount.Text)

          You should use TryParse, in case invalid chars are entered.

          Christian Graus - C++ MVP

          R 1 Reply Last reply
          0
          • C Christian Graus

            RubyM wrote:

            Dim Service As Decimal = "10.00" Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Dim messageString As String

            People used to do this in C, because they had to.  You should declare variables as you use them. So you're saying this message box doesn't show all of the messageString ? Does it show the constants you're passing in ?

            RubyM wrote:

            totalAmountOfChecks.ToString()

            I don't believe you need to call ToString, it works it out. Have you stepped through the debugger to see what's happening ?

            RubyM wrote:

            enterAmount = Decimal.Parse(txtAmount.Text)

            You should use TryParse, in case invalid chars are entered.

            Christian Graus - C++ MVP

            R Offline
            R Offline
            RubyM
            wrote on last edited by
            #5

            ok, I stepped through the debugger and don't seem to find any problems (then again, I'm am new to this and probably didn't know what to look for) the message box shows all of the messageString, but somewhere along the line it is not doing the calculations like it should. If I have the deposit button checked and enter 3 transactions of $50 then click on the "check" button and enter a transaction of $100 then choose the summary option in my menu the summary should look like this: Total Deposits: 3 Amount of Deposits: $150 Total checks: 1 Amount of Checks: $100 Total Service charge: $0 but instead it will only show this: Total Deposits: 0 Amount of Deposits: 0 Total checks: 1 Amount of checks: $100 Total Service charge: $0 I also tried it without the ToString() call and I get "0" for everything in my summary, so I do need the ToString() call. So that's my problem. It's not holding all of the transactions like it should so I can display them in my summary. Ruby

            C 1 Reply Last reply
            0
            • R RubyM

              ok, I stepped through the debugger and don't seem to find any problems (then again, I'm am new to this and probably didn't know what to look for) the message box shows all of the messageString, but somewhere along the line it is not doing the calculations like it should. If I have the deposit button checked and enter 3 transactions of $50 then click on the "check" button and enter a transaction of $100 then choose the summary option in my menu the summary should look like this: Total Deposits: 3 Amount of Deposits: $150 Total checks: 1 Amount of Checks: $100 Total Service charge: $0 but instead it will only show this: Total Deposits: 0 Amount of Deposits: 0 Total checks: 1 Amount of checks: $100 Total Service charge: $0 I also tried it without the ToString() call and I get "0" for everything in my summary, so I do need the ToString() call. So that's my problem. It's not holding all of the transactions like it should so I can display them in my summary. Ruby

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              OK, I see now.  You initially said 'I'm not seeing them'. Private Sub menSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menSummary.Click Dim Service As Decimal = "10.00" Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Dim messageString As String These are local variables.  If you declare them outside of any method, then they will be member variables, which means they will keep their values between calls to this function.

              Christian Graus - C++ MVP

              R 1 Reply Last reply
              0
              • C Christian Graus

                OK, I see now.  You initially said 'I'm not seeing them'. Private Sub menSummary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menSummary.Click Dim Service As Decimal = "10.00" Dim totalNumOfDeposit As Integer Dim totalAmtOfDeposits As Decimal Dim totalChecks As Decimal Dim totalAmountOfChecks As Decimal Dim totalAmountOfService As Decimal Dim messageString As String These are local variables.  If you declare them outside of any method, then they will be member variables, which means they will keep their values between calls to this function.

                Christian Graus - C++ MVP

                R Offline
                R Offline
                RubyM
                wrote on last edited by
                #7

                Got it!! Thanks so much for your help!! It works great now. :-D Ruby

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups