IOException in DataReceived Event Handler

dtvonly

Member
Joined
Jan 3, 2013
Messages
22
Programming Experience
5-10
Hi. VB6 was amazingly easy to use. I am a new comer to VB.NET and having problems that I did not encounter in VB6. Anyways, what is wrong with the code below for VB 2005 to complain of "...an unhandled exception of type System.IO.IOException occurred in System.dll..."


Imports System
Imports System.IO.Ports
Private Sub DataReceivedHandler(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Dim count As Integer = 17
Dim bytebuffer(17) As Byte
While count > 0
bytebuffer(17 - count) = SerialPort1.ReadByte
count = count - 1
End While
End Sub

Thanks.
 
Hi. It complain at line: bytebuffer(17 - count) = SerialPort1.ReadByte

No syntax error only this IO exception error.

IO Exception error.JPG
 
Last edited:
Back
Top