vb实时曲线的绘制问题,急,求高手。
一下程序我有几个疑问:(1)编译时提示PicScalePic'调整图像框的坐标系这句中的pic未定义,pic从何而来?怎么改?OptionExplicitDimDataF...
一下程序我有几个疑问:
(1)编译时提示PicScale Pic '调整图像框的坐标系这句中的pic未定义,pic从何而来?怎么改?
Option Explicit
Dim DataFromCom As Integer '从串口读过来的实时值
Dim DataFromComLast As Integer '上次的串口值
Dim TimeCount As Integer
Private Sub Form_Load()
PicScale Pic '调整图像框的坐标系
PicMidleLine Pic '在图像框中画一条中线
End Sub
Private Sub PicScale(picX As PictureBox) '调整图像框的坐标系
picX.Scale (0, picX.ScaleHeight)-(picX.ScaleWidth, -picX.ScaleHeight)
End Sub
Private Sub PicMidleLine(picX As PictureBox) '在图像框中画一条中线
picX.Line (0, 0)-(picX.ScaleWidth, 0), vbGreen '画出中线
End Sub
Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)
If TimeCountX - 1 > 0 Then
picX.Line ((TimeCountX - 1) * 10, DataFromComLastX)-(TimeCountX * 10, DataFromComX), vbWhite
End If
End Sub
Private Sub Timer1_Timer()
DataFromComLast = DataFromCom
Randomize
DataFromCom = 3000 * Rnd
TimeCount = TimeCount + 1
DrawRealLine Pic, TimeCount, DataFromCom, DataFromComLast '画出实时的曲线
End Sub 展开
(1)编译时提示PicScale Pic '调整图像框的坐标系这句中的pic未定义,pic从何而来?怎么改?
Option Explicit
Dim DataFromCom As Integer '从串口读过来的实时值
Dim DataFromComLast As Integer '上次的串口值
Dim TimeCount As Integer
Private Sub Form_Load()
PicScale Pic '调整图像框的坐标系
PicMidleLine Pic '在图像框中画一条中线
End Sub
Private Sub PicScale(picX As PictureBox) '调整图像框的坐标系
picX.Scale (0, picX.ScaleHeight)-(picX.ScaleWidth, -picX.ScaleHeight)
End Sub
Private Sub PicMidleLine(picX As PictureBox) '在图像框中画一条中线
picX.Line (0, 0)-(picX.ScaleWidth, 0), vbGreen '画出中线
End Sub
Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)
If TimeCountX - 1 > 0 Then
picX.Line ((TimeCountX - 1) * 10, DataFromComLastX)-(TimeCountX * 10, DataFromComX), vbWhite
End If
End Sub
Private Sub Timer1_Timer()
DataFromComLast = DataFromCom
Randomize
DataFromCom = 3000 * Rnd
TimeCount = TimeCount + 1
DrawRealLine Pic, TimeCount, DataFromCom, DataFromComLast '画出实时的曲线
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询