Ihave code written by another coder that i don't understand
Textmatrix requires a row and column
Example:
On this line how does Recap.CompanyName produce a column
FlxGrd(2).TextMatrix(i + 1, Recap.CompanyName) = .CompanyName

Form declaration

Private Type Recap_UDT CompanyName As Byte Estimator As Byte sDate As Byte BidAmount As Byte BidMaterial As Byte Bid2Amount As Byte Bid2Material As Byte sqs As Byte BusYrs As ByteEnd TypePrivate Recap As Recap_UDTEnd Form declarationPrivate Function Populate_Grid()'should have been a sub not functionDim i As IntegerDim j As Integer FlxGrd(2).Rows = RoofCompanyTotal + 1 For i = 0 To RoofCompanyTotal - 1 With RoofCompany(i) For j = 0 To FlxGrd(2).Cols - 1 FlxGrd(2).TextMatrix(i + 1, j) = vbNullString Next j FlxGrd(2).TextMatrix(i + 1, Recap.CompanyName) = .CompanyName FlxGrd(2).TextMatrix(i + 1, Recap.Estimator) = .Estimator FlxGrd(2).TextMatrix(i + 1, Recap.sDate) = .sDate FlxGrd(2).TextMatrix(i + 1, Recap.BidAmount) = .BidAmount FlxGrd(2).TextMatrix(i + 1, Recap.BidMaterial) = .BidMaterial FlxGrd(2).TextMatrix(i + 1, Recap.Bid2Amount) = .Bid2Amount FlxGrd(2).TextMatrix(i + 1, Recap.Bid2Material) = .Bid2Material FlxGrd(2).TextMatrix(i + 1, Recap.sqs) = .BusYrs 'FlxGrd(2).TextMatrix(i + 1, Recap.BusYrs) = .BusYrs End With Next SetGridSize FlxGrd(2)End Function

I'm not sure what you're asking but TextMatrix has two parameters, Row and Column, both of which need to be numbers., so let me ask you a question. What gets loaded into Recap.CompanyName? If it's a number then there's a much better way of referring to the TextMatrix column..

0

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

So somewhere, before this function is called, Recap must be assigned data to it. Recap.CompanyName will be whatever is assigned at that point, not in this function.

which is a poor way to do it. If you want to change it then please ask another question about it.

In any case your FlxGrd(2).TextMatrix(i + 1, Recap.CompanyName) = .CompanyName line now says
"The FlxGrd(2) cell with the column value equal to i+1 and row 0, is the value in RoffCompany.CompanyName"

0

isnoend2001Author Commented:

I dont understand how FlxGrd(2).TextMatrix(i + 1, Recap.CompanyName)
the column recap.companyname = a number

Essentially what Martin is saying is this. The method TextMatrix, takes a Row and Column index value as it's parameters. The row part is easy because it is determined by the i value in the for loop. The second value, which represents the column, is controlled by the Recap variable. So you identify the row and column (which equates to a cell) in the matrix that you want to update.

So lets put it all together:

Private Function Populate_Grid()Dim i As IntegerDim j As Integer ' Set the number of rows in the grid equal to the number of roof companies + 1 (the plus one is for the header row) FlxGrd(2).Rows = RoofCompanyTotal + 1 ' Let's loop through the RoofCompanyTotal value (subtracting one to avert an index out of bounds exception) For i = 0 To RoofCompanyTotal - 1 ' With the current, i, RoofCompany; the first one will be 0 and the last one will be the RoofCompanyTotal - 1. With RoofCompany(i) ' Let's loop through the columns in the row + 1 (this way we skip the header row) and set each columns text equal ' to a null string For j = 0 To FlxGrd(2).Cols - 1 FlxGrd(2).TextMatrix(i + 1, j) = vbNullString Next j ' Recap.CompanyName tells us to write text into the column that has an index of 0, the text will equal the ' current roofing company CompanyName. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.CompanyName) = .CompanyName ' Recap.Estimator tells us to write text into the column that has an index of 1, the text will equal the ' current roofing company Estimator. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.Estimator) = .Estimator ' Recap.sDate tells us to write text into the column that has an index of 2, the text will equal the ' current roofing company sDate. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.sDate) = .sDate ' Recap.BidAmount tells us to write text into the column that has an index of 3, the text will equal the ' current roofing company BidAmount. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.BidAmount) = .BidAmount ' Recap.BidMaterial tells us to write text into the column that has an index of 4, the text will equal the ' current roofing company BidMaterial. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.BidMaterial) = .BidMaterial ' Recap.Bid2Amount tells us to write text into the column that has an index of 5, the text will equal the ' current roofing company Bid2Amount. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.Bid2Amount) = .Bid2Amount ' Recap.Bid2Material tells us to write text into the column that has an index of 6, the text will equal the ' current roofing company Bid2Material. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.Bid2Material) = .Bid2Material ' Recap.sqs tells us to write text into the column that has an index of 7, the text will equal the ' current roofing company sqs. We already know that row we are dealing with. FlxGrd(2).TextMatrix(i + 1, Recap.sqs) = .BusYrs ' This is commented out so the column, if it exists, should have a null string value. 'FlxGrd(2).TextMatrix(i + 1, Recap.BusYrs) = .BusYrs End With Next SetGridSize FlxGrd(2)End Function

I note in your code that in the following code and several other places you refer to Employee and m_Employees, neither of which are defined in the code you posted. Is a module missing?

Private Sub ListEmployees()Dim emp As EmployeeDim txt As String For Each emp In m_Employees txt = txt & emp.LastName & ", " & _ emp.FirstName & vbCrLf Next emp txtEmployees.Text = txtEnd Sub

Open in new window