Home > Software engineering >  VB and serial port communication
VB and serial port communication

Time:09-22

My purpose: single chip microcomputer to send back an array to the PC Excel and save (save data process don't pop-up Excel)
But always procedure in the process of execution error, the following "factual errors 9 subscript bounds"
A great god give directions;
 Option Explicit 
Dim InByte () As Byte
Dim xlapp As Object
Dim xlBook As Object
Dim xlSheet As Object
Dim myfile As Object
Dim BytReceived () As Byte
Dim As a Integer 'definition of Excel the line


Private Sub Form_Load ()

MSComm1.Com mPort=5 'set serial port com5 _16 port 1
If MSComm1. PortOpen=False Then
MSComm1. Settings="9600, n, 8, 1" 'communication parameters (baud rate, parity, data bits, stop bit)
MSComm1. An InputMode binary accept=comInputModeBinary '
MSComm1. PortOpen=True 'open the serial port
MSComm1. InBufferCount=0 'empty the receive buffer
MSComm1. RThreshold=3 'default: when does not produce oncomm event, accept a character in the buffer region of acceptance is' producing a oncomm event, to receive data before produce oncomm event

CodePudding user response:

For I=0 To ubound (BytReceived)
XlSheet. Cells (a, I + 2)=BytReceived (I) 'factual errors 9 subscript crossing the line????
Next

CodePudding user response:

Take Excel file as ADO to deal with external database,

CodePudding user response:

Although you can use excel as a database, but in the actual application will appear all sorts of problems, and the efficiency is not high also, suggest you store the data in the MDB and SQL database, and then to write a program to regularly write excel file, which is good, and serial port communication, in particular,

CodePudding user response:

Write the database more reliable, better access than the excel

CodePudding user response:

Said comparison on 4th floor, writing and processing the data, it is better to use ACCESS, if want to write to EXCEL, or want to import it again more better

CodePudding user response:

reference litaoa reply: 3/f
although excel can be treated as a database, but in the actual application will appear all sorts of problems, and the efficiency is not high also, suggest you store the data in the MDB and SQL database, and then to write a program to regularly write excel file, which is good, especially and serial port communication,

Why can't a serial port communication will Excel as an external database to use? The trouble about reason,

CodePudding user response:

reference litaoa reply: 3/f
although excel can be treated as a database, but in the actual application will appear all sorts of problems, and the efficiency is not high also, suggest you store the data in the MDB and SQL database, and then to write a program to regularly write excel file, which is good, especially and serial port communication,

"All sorts of problems," actually has a Bug or write their own code,
"And the efficiency is not high also, than write Access to detailed records write Excel object of high efficiency,

CodePudding user response:

You start a 100% is
0 is no need to decide
Come again a=Range (" a65536 "). The End (xlUp). Row + 1

Msgbox a look at how much returned to find the problem may be more good search





CodePudding user response:

Lower the standard is lower the standard
?
The second floor of the statement to make.

Other meaningless debate

Do have this demand, nothing should shouldn't

CodePudding user response:

references 9 f aspower_ response:
lower the standard is lower the standard
?
The second floor of the statement to make.

Other meaningless debate

Do have this demand, nothing should shouldn't
using external database query, no subscript problem,
  • Related