Private Sub Timer1_Timer()
Const pi = 3.14
Const r = 1400 '表盘半径r
Dim i As Long
Dim pich As Long '高
Dim picw As Long '宽
Dim a As Single '刻度变量a
Dim b As Single '指针变量b
PictureBoard.Cls
pich = PictureBoard.Height + 1500
picw = PictureBoard.Width
PictureBoard.DrawWidth = 2
PictureBoard.ForeColor = vbBlue
For i = 0 To 10
a = (5 / 6) * pi - (i / 15) * pi
PictureBoard.Line (picw / 2 - r * Cos(a), _
pich / 2 - r * Sin(a))-(picw / 2 - (r + 200) * Cos(a), _
pich / 2 - (r + 200) * Sin(a))
'绘制刻度线, 注意刻度线的起点和终点计算方法及坐标表示
PictureBoard.CurrentY = PictureBoard.CurrentY - 180
PictureBoard.CurrentX = PictureBoard.CurrentX - 100
PictureBoard.Print Abs((i - 10) * 20)
Next i
PictureBoard.DrawWidth = 3
PictureBoard.Circle (picw / 2, pich / 2), _
r + 100, , pi / 6, 5 * pi / 6 '绘制面板上的弧线
PictureBoard.Circle (picw / 2, pich / 2), _
r, , pi / 6, 5 * pi / 6
PictureBoard.DrawWidth = 2
PictureBoard.ForeColor = vbRed
PictureBoard.Circle (picw / 2, pich / 2), _
r - 150, , pi / 6, 5 * pi / 6
PictureBoard.DrawWidth = 8
PictureBoard.ForeColor = vbGreen
PictureBoard.Circle (picw / 2, pich / 2), 60
b = (5 / 6) * pi - _
((10 - Val(Text1.Text) / 20) / 15) * pi
'从text1 中获取数据并转化为仪表指针b
PictureBoard.DrawWidth = 2
PictureBoard.ForeColor = vbGreen
PictureBoard.Line (picw / 2, pich / 2)- _
(picw / 2 - r * Cos(b), pich / 2 - r * Sin(b)) '绘制仪表指针
' b = (5 / 6) * pi - _
' ((10 - Val(Text1.Text) / 10) / 15) * pi
' '从text1 中获取数据并转化为仪表指针b
' PictureBoard.DrawWidth = 2
' PictureBoard.ForeColor = vbGreen
' PictureBoard.Line (picw / 2, pich / 2)- _
' (picw / 2 - r * Cos(b), pich / 2 - r * Sin(b)) '绘制仪表指针
Timer1.Enabled = False
End Sub
Private Sub UserControl_Initialize()
' 初始化空间
Timer1.Enabled = True
Timer1.Interval = 10
End Sub
添加一个定时器,一个图片容器和一个编辑框