Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 21,886
Better way to pull data in a loop
I'm working on something and either it's fine and I'm being picky, or it's just not right. While building a spreadsheet I need to do a check inside the loop, and pull data from an unrelated table.
Is there another and more effective way to do this instead of calling this function, is it that perfectly ok?
VB
I'm working on something and either it's fine and I'm being picky, or it's just not right. While building a spreadsheet I need to do a check inside the loop, and pull data from an unrelated table.
Is there another and more effective way to do this instead of calling this function, is it that perfectly ok?
VB
Code:
If dt IsNot Nothing And dt.Rows.Count > 0 Then
For Each dr In dt.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In dt.Columns
colIndex = colIndex + 1
wSheet.Cells(rowIndex + 1, 1) = dr("Title")
wSheet.Cells(rowIndex + 1, 2) = dr("Description")
If dr("Or") = "Y" Then
wSheet.Cells(rowIndex + 1, 3) = [B]returnVal("Select progDesc FROM Programs WHERE (Code = " & dr("ProgCode") & ")")[/B]
End If
Next
Next
End If
Last edited: