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