No announcement yet.

Sum of Grid Values

  • Filter
  • Time
  • Show
Clear All
new posts

  • Sum of Grid Values

    Good afternoon friends.

    First of all, a great New Year to you all full of peace, joy and hope.

    Now the help request:
    I am building a Grid object where values from a database are entered as Description, Expenses, and Revenue. The values posted in Expenses and Revenues must be summed and a new row inserted, where the result of the sum of each column is entered,
    What happens? ... I set up the command codes after a lot of mistakes (sometimes childish on my part) and, after a lot of work, finished the job. But when running the application, came the surprise, the sum is not being done correctly. In the displayed result only the last row of values in both columns is being considered.
    Can someone help me?
    Where am i going wrong?

    Thank you all for the attention.

  • #2

    Please can someone help me and explain why the Grid sum is not running correctly?
    The sum is only being made with the last row of the Grid.
    Has this ever happened to any of you?
    How do I solve it?
    I have been racking my brain for over a week now and can't find a solution to this problem
    I count on your help...



    • #3
      Hey man,
      Why can't you insert code instead of pictures as it is much easier for someone to help you as they have the code to play with
      From what I can see you are NOT totalling the rows
      try :
      nDespesas = nDespesas + String.ToNumber (Grid.GetCellText ("Grid_Financas",Row,2))

      instead of nTotalDespesas as you are not concating the result

      Another method is let the sqlite database do thee work for you by using SUM() then just add the result to the grid


      • #4
        OK just a little extra to check that grid cell is not empty & is a number
        cell_value = 0;
         for x = 1, Grid.GetRowCount ("Grid1")-1 do -- the loop exludes the first row (header)
             if Grid.GetCellText ("Grid1", x, 4) ~= "" and String.ToNumber (Grid.GetCellText ("Grid1", x, 4)) ~= 0 then -- checks if the cell is not empty and if the content is a number
                 cell_value = cell_value + String.ToNumber (Grid.GetCellText ("Grid1", x, 4))
         Label.SetText ("Label1", cell_value);
        Happy New Year


        • #5
          Thanks for the help charliechapser.

          You hit my mistake right ...
          I got tired of searching, but you know how it is ... Nothing like the outside look to see what we do.
          The mistake was exactly not agreeing on "nDespesas"

          Once again, thank you very much and I wish you a Happy New Year, with much peace and joy!

          Friend's hug,


          • #6

            Não coloquei o código completo, porque como já disse um amigo nosso aqui do grupo e eu tive o desprazer de confirmar isto em outro grupo. Atualmente, tem alguns espertalhões por aqui que pegam os códigos criados por nós e, quase sempre, com a ajuda de outros membros camaradas, para depois postarem em outros foruns como se fossem deles, sem dar o menor crédito de agradecimento a quem fez o serviço. Eu encontrei em outro forum o código fonte de um programinha que desenvolvi, com a ajuda do grande Ulrich, há cerca de três anos e o código de um aplicativo do nosso amigo Herrin em que o experto do larápio trocou o visual, mudou algumas coisas (mas sempre tem algo que a gente coloca no código, instintivamente, que nos identifica) para dizer aos demais que ele é um gênio (só se for na cara de pau) e se exibir.
            Fiquei extremamente chateado e triste com isto.
            Agora, se precisar enviar o código, o faço com prazer. Mas em privado. Alguns aplicativos que criamos é para ganhar um trocado e ajudar na renda em casa, porque a situação não está fácil para ninguém nos últimos anos.

            Abração mais uma vez.
            Feliz Ano Novo!



            • #7
              Sorry, I took a flight and posted in Portuguese ...


              I did not enter the full code, because as I said a friend of ours here in the group and I had the displeasure to confirm this in another group. Nowadays, there are some smarts around here who take the codes created by us and, almost always, with the help of other fellow members, and then post in other forums as their own, without giving the slightest thanks to those who did the job. . I found in another forum the source code of a little program I developed, with the help of the great Ulrich, about three years ago, and the code of an app from our friend Herrin where the larap expert changed the look, changed a few things ( but there is always something that we instinctively put into the code that identifies us) to tell others that he is a genius (only if he is in the face) and show off.
              I was extremely upset and sad about this.
              Now if I need to submit the code, I do so with pleasure. But in private. Some apps we created are to earn a little change and help with income at home, because the situation has not been easy for anyone in recent years.

              Big hug one more time.
              Happy New Year!