Const pointerLength As Integer = 600 ' gauge pointer length
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Dim pointerUnitAngle As Single ' the unit angle by which the pointer will change
Dim PI As Double ' PI= 3.14159265358979 !!
Dim numMin As Single ' the minimum gauge reading
Dim numMax As Single ' the maximum gauge reading
Dim numValue As Single ' the current gauge reading
Public Property Get min() As Single
min = numMin
End Property
Public Property Let min(mini As Single)
numMin = mini
PropertyChanged "min"
initgauge min, max
End Property
Public Property Get max() As Single
max = numMax
End Property
Public Property Let max(maxi As Single)
numMax = maxi
PropertyChanged "max"
initgauge min, max
End Property
Public Property Get value() As Single
value = numValue
End Property
Public Property Let value(reading As Single)
numValue = reading
PropertyChanged "value"
setReading reading
End Property
Private Sub setReading(curValue As Single)
curValue = curValue - min
lblReading = curValue + min
movePointer (180 + curValue * pointerUnitAngle)
' 180 to start the pointer motion at the left side of the gauge
End Sub
Private Sub initgauge(minReading As Single, maxReading As Single)
Cls
UserControl_Resize
LinePointer.X1 = UserControl.Width / 2 - 22
LinePointer.Y1 = UserControl.Height / 2 - 22
DrawGaugeLimits
If maxReading = minReading Then maxReading = minReading + 1 ' to avoid dev/zero