I think maybe PComm is not registered, so I downloaded the PComm. The DLL into the path C: \ Windows \ System32
Then run - & gt; Regsvr32 pcomm. DLL
Tips are loaded
But can't find the entrance to the
CodePudding user response:
You are using the API (Declare) import way or ActiveX DLL?CodePudding user response:
Dim X As Integer 'X is used to define a variable number of recorded data
Dim y0 defining variables As Integer 'y0 used to record the last data
Dim As Integer 'define variables Y Y is used to record the current data
Dim strData As String
Private Sub Command1_Click ()
MSComm1.Com mPort=9 'set the communication port number to COM15, this according to what you use the serial port of the
MSComm1. Settings="9600, n, 8, 1," 'said set serial port parameters, transfer rate of 4800 bit/s, no parity bit, 8 data bits, one stop bit
'this PC serial port Settings must be consistent and the lower machine
MSComm1. An InputMode=comInputModeBinary
'receive text type data is 0, if set to 1, retrieve the incoming data in the form of binary
MSComm1. PortOpen=True
'open communication port 4' True is the open ports, set to False for closed port
'if the CommPort property is set to an illegal port, will generate error 68 invalid (device)
Picture1. Scale (0, 20) - (200-20)
'define the Picture1 coordinate system, the upper left corner coordinates (0, 10) to the lower right corner coordinates (200, 10)
Picture1. Line (0, 0) - (200, 0), RGB (0, 0, 255)
'with RGB color (0,0,255) draw X
Shape1. FillColor=RGB (0, 255, 0)
'adjust light for the green
Timer1. Enabled=True
'
start Timer1 timerEnd Sub
Private Sub Timer1_Timer ()
Dim buf () As Byte 'a Byte variables
Dim As Long I
Buf=MSComm1. Input 'data in the serial receive buffer read buf variable
For I=0 To UBound (buf)
If Len (Hex (buf) (I))=1 Then
StrData=https://bbs.csdn.net/topics/strData & "0" & amp; Hex (buf) (I) & amp; "
"The Else
StrData=https://bbs.csdn.net/topics/strData & Hex (buf) (I) & "
"End the If
Text1. Text=Text1. Text & amp; StrData
If X & lt; Then=200
'if the number of the data did not reach the maximum
Y=CInt (buf (I))
'Text1 using Val function is converted to a digital and then assigned to the content of y, plus or minus sign will transform together
Picture1. PSet (X, Y), RGB (255, 0, 0)
'on the Picture1 (x, y) location in RGB color (255, 0, 0) color painting
Picture1. Line (X - 1, y0) - (X, Y), RGB (255, 0, 0)
'in the last data (x - 1, y1) and the data (x, y) used between RGB color (255, 0, 0) attachment
End the If
Next I
X=X + 1
'the data number 1
Y0=Y
'the y value assigned to a variable is used to record a data y1
Text2. Text=Text2. Text & amp; "" & amp; Hex (Y) & amp; CRH (13) & amp; CRH (10)
'Text2 number is equal to the original data and data together with the values of the data and CRH (13) & amp; CRH (10) consisting of a newline
Text2. SetFocus
Text2. SelStart=Len (Text2. Text)
'set the vertical scroll bar automatic rolling
'Text1. Text=""
'empty Text1 controls the data in the
End Sub
I am a beginner, don't know much about what you have said that, I have a piece of code is used to display a serial port data waveform, can you help me have a look at what went wrong?
The situation of application of response