VB picture控件显示实时波形求教
我的程序是上位机发送1下位机返回1通道的数据,现在是上位机发送1下位机能返回1通道的数据,上位机的text也可以显示出数值。但是这个picture显示有点问题。下位机传上来几个数值如3.30V、3.24V、0.78V 等 。这个picture显示每个电压都有好几个点,应该是一个电压一个点的。 显示程序如下,图片在压缩文件中Private Sub MSComm1_OnComm()
Dim t As String
Dim t_x(40), t_y(40) As Integer
Dim tt_y(40) As String
t = MSComm1.Input
For i = 0 To 39 Step 1
t_x(i) = i * (Picture1.Width / 50)
Next i
For i = 0 To 39 Step 1
t_y(i) = Picture1.Height - Val(Mid(t, i + 1, 1)) * (Picture1.Height / 25)
tt_y(i) = Mid(t, i + 1, 1)
Next i
If flag = 1 Then
Picture1.Cls
For i = 0 To Picture1.Width Step 100
Picture1.Line (i, 0)-(i, Picture1.Height), &HFFC0C0
Next i
For i = 0 To Picture1.Height Step 100
Picture1.Line (0, i)-(Picture1.Width, i), &HFFC0C0
Next i
For i = 0 To 39 Step 1
Picture1.Circle (t_x(i), t_y(i)), 20
Text2.Text = Text2.Text & tt_y(i)
Next i
End If
If flag = 2 Then
Picture2.Cls
For i = 0 To Picture2.Width Step 100
Picture2.Line (i, 0)-(i, Picture2.Height), &HFFC0C0
Next i
For i = 0 To Picture2.Height Step 100
Picture2.Line (0, i)-(Picture2.Width, i), &HFFC0C0
Next i
For i = 0 To 39 Step 1
Picture2.Circle (t_x(i), t_y(i)), 20
Text3.Text = Text3.Text & tt_y(i)
Next i
End If
If flag = 3 Then
Picture3.Cls
For i = 0 To Picture3.Width Step 100
Picture3.Line (i, 0)-(i, Picture3.Height), &HFFC0C0
Next i
For i = 0 To Picture3.Height Step 100
Picture3.Line (0, i)-(Picture3.Width, i), &HFFC0C0
Next i
For i = 0 To 39 Step 1
Picture3.Circle (t_x(i), t_y(i)), 20
Text4.Text = Text4.Text & tt_y(i)
Next i
End If
If flag = 4 Then
Picture4.Cls
For i = 0 To Picture4.Width Step 100
Picture4.Line (i, 0)-(i, Picture4.Height), &HFFC0C0
Next i
显示波形图片.zip
(34.22 KB)
For i = 0 To Picture4.Height Step 100
Picture4.Line (0, i)-(Picture4.Width, i), &HFFC0C0
Next i
For i = 0 To 39 Step 1
Picture4.Circle (t_x(i), t_y(i)), 20
Text5.Text = Text5.Text & tt_y(i)
Next i
End If