Link to home
Start Free TrialLog in
Avatar of ChanderMadhavi
ChanderMadhavi

asked on

Create a display screen

Hi

I REALLY NEED TO GET THIS DONE. And hopefully this will be the last question I am asking.

I select statement which return the following

Col1      Col2
1            a
2            b
3            c
4            d

Depending on the criteria the number of rows returned varies.
From this information I have to display the following.

1     a          a+b       a+b+c           a+b+c+d
2                  b            B+c             b+c+d
3                                c                c+d
4                                                   d


Could someone Please help me how would I display it?
Would it be easier to do in vb.net (I am new to it!) or which other way would you suggest???
Avatar of cookre
cookre
Flag of United States of America image

Use whichever language you're comfortable with - the approach would be the same in all.

You have 16 fields, the bottom left 6 of which will always be blank.  The rest you valued or clear depending on how many row you got.

..unless I've completely misunderstood you (it happens)
Avatar of Mike Tomlinson
The problem can easily be solved via a recursive algorithm and shouldn't be hard to implement.
Couple of questions though:

1) Do want the literal values concatentated together with + symbols...or are you computing the sum of the values?
2) What do you want the output to be in?  A text file?  Some kind of grid?
3) Where is the input data coming from?  An array?  Some kind of collection?  A grid?
4) What language do you want?  VB.Net?  VB6? something else?....

Idle_Mind
Avatar of ChanderMadhavi
ChanderMadhavi

ASKER

1) I am computing the sum of the values a, b, c, d are values which need to be added.

2) the output needs to be in a grid

3) the input data comes from a query  The result comes out as a data set. I could use the select statement and create stored procedure in SQL and manipulate results never done it before. Else could do it in VB.net

4) The number of rows returned by a query could differ example if rows are 6 the grid would be

Col1      Col2
1            a
2            b
3            c
4            d
5            e
6            f

Depending on the criteria the number of rows returned varies.
From this information I have to display the following.

1     a          a+b       a+b+c           a+b+c+d      a+b+c+d+e   a+b+c+d +e+f
2                  b            B+c             b+c+d            b+c+d+e       b+c+d+e+f
3                                c                c+d                   c+d+e           c+d+e+f
4                                                   d                      d+e                d+e+f
5                                                                             e                     e+f
6                                                                                                      f

1)      Create array the size of your recordset.
2)      Move your data from the recordset to the array.
3)      Create a RowIndex loop that goes from bottom of the array to the top of the array.
                a.      Set SUM = 0
                b.      Create a ColIndex loop that goes from the current RowIndex to the top of the array.
                               i.      SUM = SUM + Array(ColIndex)
                               ii.      SET Grid(RowIndex, ColIndex) = SUM

In code it would look something like this:
    numCols = rs.RecordCount
    Dim values(numCols - 1) as long
    ColIndex = 0
    While Not (rs.EOF)
        values(ColIndex) = rs.Fields("Col2")
        ColIndex = ColIndex + 1
    Wend
   
    For RowIndex = 0 To numCols - 1
        sum = 0
       
        For ColIndex = RowIndex To numCols - 1
            sum = sum + values(ColIndex)
            grid(RowIndex, ColIndex) = sum
        Next
    Next

Opps...need to move to the next record in the loop

values(ColIndex) = rs.Fields("Col2")
rs.movenext
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi
I really really appreciate your immediate reply. But I realise that the stuff is vb.net windows application. I am looking at the same thing in Vb.net web application. Could you please help me. You were very fast in doing it too.
Thanks
Madhavi
Hi

I got it working with a web application.
THANKS A LOT. Can I award you bonus points!!!. I really would like to!
Madhavi
No need for bonus points...Thank you though!

Glad you got it to work with your web app.

Idle_Mind