Private Sub Timer1_Timer()
Dim currenttemp, selectedtemp, a, b, c As Integer
selectedtemp = selectedtemptext.Text
currenttemp = Int(((selectedtemp + 15) - selectedtemp + 1) * Rnd + selectedtemp)
'read currenttemp
Select Case currenttemp
Case Is = selectedtemp: a = 0
Case Is = (selectedtemp + 1): a = 12
Case Is = (selectedtemp + 2): a = 24
Case Is = (selectedtemp + 3): a = 36
Case Is = (selectedtemp + 4): a = 48
Case Is = (selectedtemp + 5): a = 60
Case Is = (selectedtemp + 6): a = 72
Case Is = (selectedtemp + 7): a = 84
Case Is = (selectedtemp + 8): a = 96
Case Is = (selectedtemp + 9): a = 108
Case Is = (selectedtemp + 10): a = 120
Case Is = (selectedtemp + 11): a = 132
Case Is = (selectedtemp + 12): a = 144
Case Is = (selectedtemp + 13): a = 156
Case Is = (selectedtemp + 14): a = 168
Case Is = (selectedtemp + 15): a = 180
Case Is > (selectedtemp + 15): a = 180
Case Is < selectedtemp: a = 0
Case Else
End Select
'12,24,36,48,60,72,84,96,108,120,132,144,156,168,180
'a = currenttemp - selectedtemp
Cls
If currenttemp < (selectedtemp + 1) Then
'set g to 0 if current temp is colder then selected temp
'and draw meter to 0
g = 0
Line1.X1 = 500
Line1.Y1 = 500
Line1.X2 = 140
Line1.Y2 = 500
Else
If a > 179 Then
'set g = 1 and draw meter at 180 because temp is too hot
g = 1
Line1.X1 = 500
Line1.Y1 = 500
Line1.X2 = 860
Line1.Y2 = 500
Else
If a > -1 And a < 91 Then
'draw meter if temp falls on left hand side
b = -(360 * (Sin((a) * 0.017453292)))
c = -(360 * (Cos((a) * 0.017453292)))
'Line (1000, 1000)-Step(c, b)
Line1.X1 = 500
Line1.Y1 = 500
Line1.X2 = c
Line1.Y2 = b
Else
If a > 90 And a < 181 Then
'draw meter if temp falls on right hand side
b = (360 * (Sin((a - 90) * 0.017453292)))
c = -(360 * (Cos((a - 90) * 0.017453292)))
'Line (1000, 1000)-Step(b, c)
Line1.X1 = 500
Line1.Y1 = 500
Line1.X2 = (b + 500)
Line1.Y2 = c
End If
End If
End If
End If
End Sub