I have inherited someone's bad code to try and fix, in this code there are 15 entries per day and are names as follows:
Mon01, Mon02, Mon03, Mon04, etc
I then have a grid with the same number of entries, I need to check if the value of Mon01 matches the first entry in the grid, if not then update its value. But as I said there are 7 grids so 7*15, so instead of having 105 lines of code i'd rather have 4.
My question is, is there a way to loop through and change the values of these variables. An example idea is:
for (i = 0; i < 15; i++)
variable = "Mon" + i
If (variable.value <> Grid.TextArray(i) Then
variable.value = Grid.TextArray(i)
End If
End For
I know the above isn't valid VB6 code, but its trying to get the message across best way I can.
My current revised code looks like this:
DB.Recordsource = "QUERY REMOVED"
Call DB.GetData(RS)
With RS
Dim ChangeArray() As String
If Trim(MonGrid.TextArray((1 * MonGrid.Cols) + 2)) <> ![Mon01] Then
![Mon01] = MonGrid.TextArray((1 * MonGrid.Cols) + 2)
ReDim Preserve ChangeArray(0 To UBound(ChangeArray) + 1) As String
End If