|
-
March 10th, 2012, 08:59 AM
#1
Remove Blanks from a Grid(DataWidget)
Hello, I have a grid in which I need to be able to manipulate. If there are any blanks, then these need to be moved to the bottom and all the numbers below it should be moved up.
I am using VB6

Current Grid (blanks are shown here as asterisk)
5 6 1 4 9 3
7 8 3 * 1 5
9 * 5 * 3 *
1 2 7 6 5 9
Need it to be:
5 6 1 4 9 3
7 8 3 6 1 5
9 2 5 * 3 9
1 * 7 * 5 *
I need to read the grid column by column. If a blank is found, I need to move everything up and place the blanks at the end of the column.
For example in the 2nd column I have:
6
8
*
2
I need this to become
6
8
2
*
There might be more than one blank and more than one blank in a row. For example in the 4th column I have:
4
*
*
6
I need this to become
4
6
*
*
As an example of how the grid is named. Here is a small code section that shows how the program will swap numbers. For example in column 1 if I change the 7 to a 1, the grid changes from:
5
7
9
1
To
5
1
9
7
Code:
For X = FrmMain.grid.Rows - 1 To 0 Step -1
FrmMain.grid.Row = X
If FrmMain.grid.Columns(UpdateCol).Value = newValue And FrmMain.grid.Row <> rRow Then
FrmMain.grid.Columns(UpdateCol).Value = oldValue
Exit For
End If
Next
I am showing this code just so you have the naming convention for the grid and how I have been coding other areas.
Thank in advance for reading this post, and any help is greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|