Mark,
This is the code I am currently using to read the values into an array from the RealTime.txt file (which is loaded into TextBox2),
and then assigned to various Labels, please see VB.NET code snippet below.
Could this be causing the problem as they are "Strings"?
FYI. I have not wrapped the code in code tags, as I wanted to be able to BOLD and use Colours to
highlight parts of the code to heopfully make it easier for me to explain.
/// CODE SNIPPET START ///
'Puts values from RealTime.txt (being displayed in TextBox), into and Array and shows them on Labels.
Dim strMRD As String
Dim strArr() As String
Dim count As Integer
strMRD = TextBox2.Text
strArr = strMRD.Split(" ")
For count = 0 To strArr.Length - 1
Label1.Text = strArr(0) 'date (always dd/mm/yy)
Label2.Text = strArr(1) 'time(always hh:mm:ss)
Label3.Text = strArr(2) 'outside temperature
Label4.Text = strArr(3) 'relative humidity
Label5.Text = strArr(4) 'dewpoint
Label6.Text = strArr(5) 'wind speed (average)
Label7.Text = strArr(6) 'latest wind speed reading
Label8.Text = strArr(7) 'wind bearing (degrees)
Label9.Text = strArr(8) 'current rain rate (per hour)
Label10.Text = strArr(9) 'rain today
Label11.Text = strArr(10) 'barometer
Label12.Text = strArr(11) 'current wind direction (compass point)
Label13.Text = "F" + strArr(12) 'wind speed (beaufort)
Label14.Text = strArr(13) 'wind units - m/s, mph, km/h, kts
Label15.Text = "°" + strArr(14) 'temperature units - degree C, degree F
Label16.Text = strArr(15) 'pressure units - MB, hPa, in
Label17.Text = strArr(16) 'rain units - mm, in
Label18.Text = strArr(17) 'wind run (today)
Label19.Text = strArr(18) 'pressure trend value
Label20.Text = strArr(19) 'monthly rainfall
Label21.Text = strArr(20) 'yearly rainfall
Label22.Text = strArr(21) 'yesterday's rainfall
Label23.Text = strArr(22) 'inside temperature
Label24.Text = strArr(23) 'inside humidity
Label25.Text = strArr(24) 'wind chill
Label26.Text = strArr(25) 'temperature trend value
Label27.Text = strArr(26) 'today's high temp
Label28.Text = "@ " + strArr(27) 'time of today's high temp (hh:mm)
Label29.Text = strArr(28) 'today's low temp
Label30.Text = "@ " + strArr(29) 'time of today's low temp (hh:mm)
Label31.Text = strArr(30) 'today's high wind speed (average)
Label32.Text = "@ " + strArr(31) 'time of today's high wind speed (average) (hh:mm)
Label33.Text = strArr(32) 'today's high wind gust
Label34.Text = "@ " + strArr(33) 'time of today's high wind gust (hh:mm)
Label35.Text = strArr(34) 'today's high pressure
Label36.Text = "@ " + strArr(35) 'time of today's high pressure (hh:mm)
Label37.Text = strArr(36) 'today's low pressure
Label38.Text = "@ " + strArr(37) 'time of today's low pressure (hh:mm)
Label39.Text = strArr(38) 'Cumulus version
Label40.Text = strArr(39) 'Cumulus build number
Label41.Text = strArr(40) '10-minute high gust
Label42.Text = strArr(41) 'heat index
Label43.Text = strArr(42) 'humidex
Label44.Text = strArr(43) 'UV Index
Label45.Text = strArr(44) 'evapotranspiration today
Label46.Text = strArr(45) 'solar radiation W/m2
Label47.Text = strArr(46) '10-minute average wind bearing (degrees)
Label48.Text = strArr(47) 'rainfall last hour
Label49.Text = strArr(48) 'The number of the current forecasts
Label50.Text = strArr(49) 'Flag to indicate that the location of the station is currently in daylight (1 = yes, 0 = No)
Label51.Text = strArr(50) 'If the station has lost contact with its remote sensors "Fine Offset only", a Flag number is given (1 = Yes, 0 = No)
Label52.Text = strArr(51) 'Average wind direction
Label53.Text = strArr(52) 'Cloud base
Label54.Text = strArr(53) 'Cloud base units
Label55.Text = strArr(54) 'Apparent Temperature
Label56.Text = strArr(55) 'Sunshine hours so far today
Label57.Text = strArr(56) 'Current theoretical max solar radiation
Label58.Text = strArr(57) 'Is it sunny? 1 if the sun is shining, otherwise 0
/// CODE SNIPPET END ///
The Sub below is how I assign the values held by the labels, Label: 3, 5 & 25 to the graphical chart
shown in
Bold in both the above and below code snippets. As you can see in
red
below I have given the Variables OutsideTemp, DewPoint and WindChill a data type of "Single", which I previously
had as an "Integer" which may have been causing problems.
But my main thought is that if I have already pulled the values into the array (in the above code) as strings
when I then try to change them to "Single" in the below code, the damage is already done to the value
and they won't be accepted as true "Single" if you know what I mean
hopefully that makes sence LOL
/// CODE SNIPPET START ///
Private Sub PlotChart()
Dim s As New Series
Dim OutsideTemp As
Single
Dim DewPoint As
Single
Dim WindChill As
Single
Chart1.Series.Dispose()
Chart1.Series.Clear()
'Makes Chart visible on [Outside Conditions] tab screen
Chart1.Visible = True
On Error Resume Next
'Create a new series and add data points to it.
'Dim s As New Series
s.Name = "Temp °C"
'Clears Chart
Chart1.Series.Clear()
'Sets Y Axis Title, to Temperature and the Temperature unit from Label15
Chart1.ChartAreas(0).AxisY.Title = "Temperature " + Label15.Text
'Chart1.ChartAreas(0).AxisY.Interval = 1
OutsideTemp =
Label3.Text
DewPoint =
Label5.Text
WindChill =
Label25.Text
'Change to a line graph.
's.ChartType = SeriesChartType.Line
s.ChartType = SeriesChartType.Column
s.Points.AddXY("Temp", OutsideTemp)
s.Points.AddXY("Dew Point", DewPoint)
s.Points.AddXY("Wind Chill", WindChill)
'resets AutoValues and resizes chart to the largest value.
Chart1.ResetAutoValues()
'Add the series to the Chart1 control.
Chart1.Series.Add(s)
End Sub
/// CODE SNIPPET END ///