How to fill in empty parts of array?
Hi all I am writing a program that turns a text weather forecast into tabular data. I use regex to split the forecast into elements, then place then into an array with a few loops. I am having one problem though. I use a loop to place the max temp and min temp into the array and fill in the values in between, but I can't figure out how to fill the values in on either side of the temps. here is my code
Code:
PublicSub CreateTemps()
Dim I, x AsInteger
'Holds the Values from the regex of teh temperatures
Dim HighTime, LowTime, HighTemp, LowTemp AsInteger
'first time cooisides with whatever time taf starts at
Dim time1, time2 AsInteger
'Holds the diffrences between times and temps
Dim TimeDiff, TempDiff AsInteger
Dim Counter AsInteger
'Calculates the numarical values for the high and low temp times
If TabDataGrid(2, 0) - TempCollection.Groups("HIGHT").Value <= 0 Then
HighTime = Abs(TabDataGrid(2, 0) - TempCollection.Groups("HIGHT").Value)
Else : HighTime = Abs((TabDataGrid(2, 0) - TempCollection.Groups("HIGHT").Value) - 24)
EndIf
If TabDataGrid(2, 0) - TempCollection.Groups("LOWT").Value <= 0 Then
LowTime = Abs(TabDataGrid(2, 0) - TempCollection.Groups("LOWT").Value)
Else : LowTime = Abs((TabDataGrid(2, 0) - TempCollection.Groups("LOWT").Value) - 24)
EndIf
'these are the temperature values
LowTemp = TempCollection.Groups("LOW").Value
HighTemp = TempCollection.Groups("HIGH").Value
'Diffrences between temps and temp times
TempDiff = Abs(LowTemp - HighTemp)
TimeDiff = Abs(HighTime - LowTime)
'The tempdiff divided by the timediff give you the interval between each temp
Counter = Round((TempDiff / TimeDiff), 0)
'creates array of temps from the low temp to the high temp
' their are 2 becuase there are 3 diffrent forecasts 11Z,19Z,03Z The high temp won't always be first
For I = LowTime + 1 To TimeDiff
TabDataGrid(12, I) = LowTemp
LowTemp += Counter
TabDataGrid(12, LowTime) = TempCollection.Groups("LOW").Value
TabDataGrid(12, HighTime) = TempCollection.Groups("HIGH").Value
Next I
For I = HighTime To TimeDiff
TabDataGrid(12, I) = HighTemp
HighTemp -= Counter
TabDataGrid(12, LowTime) = TempCollection.Groups("LOW").Value
TabDataGrid(12, HighTime) = TempCollection.Groups("HIGH").Value
Next I
EndSub