pic.line 画出来的为什么是一个个点呢
Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)If TimeCountX - 1 > 0 And (TimeCountX - 1) * 15 < pic.Width Then
picX.Line ((TimeCountX - 1) * 15, DataFromComLastX * 70)-(TimeCountX * 15, DataFromComX * 70), vbBlue
End If
If (TimeCountX - 1) * 15 > pic.Width Then
TimeCount = 0
pic.Cls
End If
End Sub
这是画实时曲线的函数,理论上画出来的应该是线而不是点,但我画出来的却是一个个点,怎么回事呢?
附
Option Explicit
Dim DataFromCom As Integer
Dim DataFromComLast As Integer
Dim TimeCount As Integer
Private Sub Check1_Click()
If Check1.Value = 1 Then
MSComm1.InBufferSize = 1024
MSComm1.InBufferCount = 0
MSComm1.InputMode = 1
= 3
MSComm1.Settings = "9600,N,8,1"
Check2.Enabled = False
End If
If Check1.Value = 0 Then
Timer1.Enabled = False
Check2.Enabled = True
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
MSComm1.InBufferSize = 1
MSComm1.InBufferCount = 0
MSComm1.InputMode = comInputModeText
= 2
MSComm1.Settings = "9600,N,8,1"
Check1.Enabled = False
End If
If Check2.Value = 0 Then
Timer1.Enabled = False
Check1.Enabled = True
End If
End Sub
Private Sub Command1_Click(Index As Integer)
'Timer1.Enabled = True
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End Sub
Private Sub Command2_Click(Index As Integer)
Timer1.Enabled = False
MSComm1.PortOpen = False
End Sub
Private Sub Command3_Click()
Unload Form1
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If
End Sub
Private Sub Form_Load()
Timer1.Interval = 1
Timer1.Enabled = False
PicScale pic
End Sub
Private Sub PicScale(picX As PictureBox)
picX.Scale (0, 8750)-(picX.ScaleWidth, -1400)
End Sub
Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)
If TimeCountX - 1 > 0 And (TimeCountX - 1) * 15 < pic.Width Then
picX.Line ((TimeCountX - 1) * 15, DataFromComLastX * 70)-(TimeCountX * 15, DataFromComX * 70), vbBlue
End If
If (TimeCountX - 1) * 15 > pic.Width Then
TimeCount = 0
pic.Cls
End If
End Sub
Private Sub MSComm1_OnComm()
Dim byte1() As Byte
Dim a As Byte
Dim b As Byte
Dim s As Integer
If MSComm1.InBufferCount > 0 Then
byte1 = MSComm1.Input
a = byte1(0)
b = byte1(1)
s = a * 256 + b
Text1.Text = s
DataFromCom = Text1
DataFromComLast = DataFromCom
TimeCount = TimeCount + 1
DrawRealLine pic, TimeCount, DataFromCom, DataFromComLast
End If
End Sub 这是整段编程