Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Diem Tran   on Jan 02 In MS Office Category.

  
Question Answered By: Cara Lewis   on Jan 02

Do you have a code  for your serial I/O speadsheet ??
Not sure if we are at the same frequency, what I am trying to do is
to retrieve data from a serial port and display on a spreadsheet.
Here's my code snippet

Private Sub MSComm1_OnComm()
Dim sData As String ' Holds our incoming data
Dim DataIn As Variant
Dim lHighByte As Long ' Holds HighByte value
Dim lLowByte As Long ' Holds LowByte value
Dim lWord As Long ' Holds the Word result

' If comEvReceive Event then get data and display
If MSComm1.CommEvent = comEvReceive Then

sData = MSComm1.Input ' Get data (2 bytes)
lHighByte = Asc(Mid$(sData, 1, 1)) ' get 1st byte
lLowByte = Asc(Mid$(sData, 2, 1)) ' Get 2nd byte

' Combine bytes into a word
lWord = (lHighByte * &H100) Or lLowByte

Cells(1, 1).Value = (lWord)
End If
End Sub

It works for a short while, and after a few seconds it display an
error message as follows

" application-defined or object-defined error"

Any clue where goes wrong ??

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on newbie questions Or get search suggestion and latest updates.


Tagged: