filling in empty array sections

clowns119

Member
Joined
Feb 17, 2005
Messages
8
Programming Experience
1-3
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
VB.NET:
 [size=2]
[/size][size=2][color=#0000ff]Public[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] CreateTemps()
 
[/size][size=2][color=#0000ff]Dim[/color][/size][size=2] I, x [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
[/color][/size][size=2][color=#008000]'Holds the Values from the regex of teh temperatures
 
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] HighTime, LowTime, HighTemp, LowTemp [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
[/color][/size][size=2][color=#008000]'first time cooisides with whatever time taf starts at
 
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] time1, time2 [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
 
 
[/color][/size][size=2][color=#008000]'Holds the diffrences between times and temps
 
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] TimeDiff, TempDiff [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
[/color][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] Counter [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Integer
 
[/color][/size][size=2][color=#008000]'Calculates the numarical values for the high and low temp times
 
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] TabDataGrid(2, 0) - TempCollection.Groups("HIGHT").Value <= 0 [/size][size=2][color=#0000ff]Then
 
[/color][/size][size=2]HighTime = Abs(TabDataGrid(2, 0) - TempCollection.Groups("HIGHT").Value)
 
[/size][size=2][color=#0000ff]Else[/color][/size][size=2] : HighTime = Abs((TabDataGrid(2, 0) - TempCollection.Groups("HIGHT").Value) - 24)
 
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
 
 
 
[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2] TabDataGrid(2, 0) - TempCollection.Groups("LOWT").Value <= 0 [/size][size=2][color=#0000ff]Then
 
[/color][/size][size=2]LowTime = Abs(TabDataGrid(2, 0) - TempCollection.Groups("LOWT").Value)
 
[/size][size=2][color=#0000ff]Else[/color][/size][size=2] : LowTime = Abs((TabDataGrid(2, 0) - TempCollection.Groups("LOWT").Value) - 24)
 
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If
 
[/color][/size][size=2][color=#008000]'these are the temperature values
 
[/color][/size][size=2]LowTemp = TempCollection.Groups("LOW").Value
 
HighTemp = TempCollection.Groups("HIGH").Value
 
[/size][size=2][color=#008000]'Diffrences between temps and temp times
 
[/color][/size][size=2]TempDiff = Abs(LowTemp - HighTemp)
 
TimeDiff = Abs(HighTime - LowTime)
 
[/size][size=2][color=#008000]'The tempdiff divided by the timediff give you the interval between each temp 
 
[/color][/size][size=2]Counter = Round((TempDiff / TimeDiff), 0)
 
[/size][size=2][color=#008000]'creates array of temps from the low temp to the high temp
 
[/color][/size][size=2][color=#008000]' their are 2 becuase there are 3 diffrent forecasts 11Z,19Z,03Z The high temp won't always be first
 
[/color][/size][size=2][color=#0000ff]For[/color][/size][size=2] I = LowTime + 1 [/size][size=2][color=#0000ff]To[/color][/size][size=2] TimeDiff
 
TabDataGrid(12, I) = LowTemp
 
LowTemp += Counter
 
TabDataGrid(12, LowTime) = TempCollection.Groups("LOW").Value
 
TabDataGrid(12, HighTime) = TempCollection.Groups("HIGH").Value
 
[/size][size=2][color=#0000ff]Next[/color][/size][size=2] I
 
[/size][size=2][color=#0000ff]For[/color][/size][size=2] I = HighTime [/size][size=2][color=#0000ff]To[/color][/size][size=2] TimeDiff
 
TabDataGrid(12, I) = HighTemp
 
HighTemp -= Counter
 
TabDataGrid(12, LowTime) = TempCollection.Groups("LOW").Value
 
TabDataGrid(12, HighTime) = TempCollection.Groups("HIGH").Value
 
[/size][size=2][color=#0000ff]Next[/color][/size][size=2] I
 
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Sub
 
[/color][/size]
 
Back
Top