赞
踩
利用vb的picture控件进行曲线图表绘图,圆形来源于百度。
声明 :
Option Explicit
Dim X As Long
Dim Y As Long
Dim 高间格 As Long, 宽间格 As Long
更新绘制:
Private Sub Command1_Click()
'测试按钮 ,定时器里的代码与此相同
Picture1.Cls
Call 绘折线图(Picture1) '绘制折线图
' Stop
End Sub
曲线表格:
Public Sub 绘折线图(cs As PictureBox)
Dim i As Long, 间格 As Double
Dim 总高 As Long
Dim 最低格 As Double
With cs
总高 = .ScaleHeight - 200
高间格 = (总高) / 12 '上下各留一格
宽间格 = (.ScaleWidth - 600) / 51 '右边留一格
.Cls '清屏
'画坐标
Dim x1 As Long, X2 As Long, y1 As Long, y2 As Long
y1 = .ScaleHeight - 200
x1 = .ScaleWidth - 200
cs.Line (600, 0)-(600, y1), vbGreen
cs.Line (600, y1)-(.ScaleWidth, y1), vbGreen
'画坐标网络
.ForeColor = vbBlack
.CurrentX = 0
.CurrentY = y1 - 90
cs.Print Round(最低格, 3)
For i = 1 To 11
cs.Line (600, y1 - i * 高间格)-(.ScaleWidth, y1 - i * 高间格), vbBlack
.CurrentX = 0
.CurrentY = y1 - i * 高间格 - 90
cs.Print Round(20 * i, 3)
Next i
For i = 1 To 50
cs.Line (600 + i * 宽间格, 0)-(600 + i * 宽间格, y1), vbRed
.CurrentX = 600 + i * 宽间格 - 150
.CurrentY = y1 + 30
cs.Print i
Next i
End With
End Sub
可以利用time控件输入一个随机曲线进行测试。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。