All,
I have what I thought would be a simple sort operation, i've done them and used them before but cannot for the life of me work out why this one does not work
Here is the code;
Here is the result;
No matter what I try I cannot get the lowest value out of the list - highest value not a problem, but cannot get the lowest (should be 21 in this example), I set the values for MinVal4 and MaxVal4 just to test it and if I change MinVal4 in the declarations then it appears in the debug statements - its like its not even checking through the records for the smallest. If I change it to 0 in the declarations then I get 0 for the minimum.
Any help gratefully received...
I have what I thought would be a simple sort operation, i've done them and used them before but cannot for the life of me work out why this one does not work
Here is the code;
Code:
Dim MinVal4 As Decimal = 15 Dim MaxVal4 As Decimal = 15 While SQLreader.Read() hs.writelog("Test", SQLreader(0)) If MinVal4 > CDec(SQLreader(0)) Then MinVal4 = CDec(SQLreader(0)) If MaxVal4 < CDec(SQLreader(0)) Then MaxVal4 = CDec(SQLreader(0)) End While Call WriteMessage("Sensor 4 Min: " & MinVal4, MSG_DEBUG) Call WriteMessage("Sensor 4 Max: " & MaxVal4, MSG_DEBUG)
Here is the result;
PHP Code:
29/04/2011 21:08:19 Test 21.12
29/04/2011 21:08:19 Test 21.12
29/04/2011 21:08:19 Test 21.12
29/04/2011 21:08:19 Test 21.12
29/04/2011 21:08:19 Test 21.25
29/04/2011 21:08:19 Test 21.25
29/04/2011 21:08:19 Test 21.18
29/04/2011 21:08:19 Test 21.31
29/04/2011 21:08:19 Test 21.43
29/04/2011 21:08:19 Test 21.5
29/04/2011 21:08:19 Test 21.37
29/04/2011 21:08:19 Test 21.56
29/04/2011 21:08:19 Test 21.5
29/04/2011 21:08:19 Test 21.43
29/04/2011 21:08:19 Test 21.37
29/04/2011 21:08:19 Test 21.37
29/04/2011 21:08:19 Test 21.37
29/04/2011 21:08:19 Test 21.18
29/04/2011 21:08:19 Test 21.06
29/04/2011 21:08:19 Test 21.12
29/04/2011 21:08:19 Test 21.18
29/04/2011 21:08:19 Test 21.06
29/04/2011 21:08:19 Test 21.12
29/04/2011 21:08:19 Test 21.18
29/04/2011 21:08:19 Test 21
29/04/2011 21:08:19 DS1820 (3P) Debug Sensor 4 Min: 15
29/04/2011 21:08:19 DS1820 (3P) Debug Sensor 4 Max: 21.56
Any help gratefully received...
Comment