How can one put MSHFlexgrid data from 2 flexgrids into a single grid using VB6?

I have 3 VB6 MSHFlexGrids. Grid1 and Grid2 have data, Grid3 is blank.
[1] I want to put all the data from Grid1---say, 30 rows---into Grid3.
[2] I then want to append all the Grid2 data onto the end of the Grid3 data that just came from #1 as stated above.
[3] The amount of data in Grid1 and Grid2 will vary, so the code should consider looking for the first blank row of Grid3 when doing #2 above
[4] We're not talking a huge amount of data in Grid1 or Grid2----about 20 to 30 rows or in each grid would be the maximum

How can I do this? Most of the information I can find talks about 'combining' data in cells or rows----I just want to make one contiguous set of records in Grid3. Many thanks in advance for any assistance.
LVL 4
jazjefAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
I'll create a demo project for you. Be back soon.
0
Martin LissOlder than dirtCommented:
Here's some code. Note that in the "Fill Grid3" part it assumes that if any cell in a grid is blank, then that's the end of the data in that grid.

Dim r As Integer
Dim c As Integer
Dim intNewRow As Integer

' Generate test data
For r = 0 To 10
    For c = 0 To Grid1.Cols - 1
        Grid1.TextMatrix(r, c) = r * c
    Next
Next
For r = 0 To 5
    For c = 0 To Grid2.Cols - 1
        Grid2.TextMatrix(r, c) = r * c + 5
    Next
Next

' Fill Grid3
For r = 0 To Grid1.Rows - 1
    For c = 0 To Grid1.Cols - 1
        If Grid1.TextMatrix(r, c) <> "" Then
            intNewRow = r + 1
            Grid3.TextMatrix(r, c) = Grid1.TextMatrix(r, c)
        End If
    Next
Next

For r = 0 To Grid2.Rows - 1
    For c = 0 To Grid2.Cols - 1
        If Grid2.TextMatrix(r, c) <> "" Then
            Grid3.TextMatrix(intNewRow, c) = Grid2.TextMatrix(r, c)
        End If
    Next
    intNewRow = intNewRow + 1
Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jazjefAuthor Commented:
Works perfectly MartinLiss.....MANY thanks once again. I just set Grid3 rows to equal Grid1 rows + Grid2 rows so Grid3 always has room for the transaction.
0
Martin LissOlder than dirtCommented:
Once again you're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.