Hi all,
I think I should be able to do what I want here, but it doesn't appear to be working - I can find where, but I don't understand why so hopefully someone can point out my mistake.
Background:
Programming Platform: VB 6
Files: 1) form1
2) module1
I'm working at figuring out "generic" functions. For example, I have a certain formatting I want to start MSHFlexGrid controls at (quantity of columns, quantity of rows, etc.).
So, I created a sub to learn with:
Sub test(ByVal HoldGrid As MSHFlexGrid)
Dim row As String
Dim v As Integer
HoldGrid.Rows = 20
HoldGrid.Cols = 12
'For v = 1 To 17 Step 4
' HoldGrid.row = v
' HoldGrid.Col = 1
' HoldGrid.RowSel = v
' HoldGrid.ColSel = 12
' HoldGrid.CellBackColor = RGB(189, 212, 246)
' HoldGrid.CellAlignment = flexAlignCenterCenter
' HoldGrid.MergeCells = flexMergeRestrictRows
'Next x
' HoldGrid.MergeRow(1) = True
' HoldGrid.MergeRow(5) = True
' HoldGrid.MergeRow(9) = True
' HoldGrid.MergeRow(13) = True
' HoldGrid.MergeRow(17) = True
HoldGrid.row = 1
'Form1.HoldGrid.Col = 1
For v = 1 To 12
HoldGrid.Col = v
HoldGrid.Text = "row1"
Next v
HoldGrid.row = 5
For v = 1 To 12
HoldGrid.Col = v
HoldGrid.Text = "row5"
Next
MsgBox "I'm here now", , "Made it to 1"
HoldGrid.row = 9
For v = 1 To 12
HoldGrid.Col = v
HoldGrid.Text = "row9"
Next v
HoldGrid.row = 13
For v = 1 To 12
HoldGrid.Col = v
HoldGrid.Text = "row13"
Next v
MsgBox "I'm there now", , "Made it to 2"
HoldGrid.row = 17
For v = 1 To 12
HoldGrid.Col = v
HoldGrid.Text = "row 17"
Next v
End Sub
This subroutine is stored in Module 1.
Module 1 sub main runs the program, it first loads the form, shows it and then calls:
test Form1.DataGrid
Now, as I see it the way I have the subroutine programmed, it should perform each for next loop within the subroutine and then exit the sub.
Here's the problem - it works fine until the end of the first for...next loop at which time it just dumps out of the subroutine (notice the MsgBox's I had put in for initial debuging, neither popped up so I stepped thru and found that it would go thru the first uncommented for-next loop and then just exit the subroutine like I had requested it)...
Am I not allowed to do this, or am I going about it the wrong way some how? any suggestions would be most appreciated.
Start Free Trial