Mike, Your code seems to work like a charm! Thanks. Dan ----- Original Message ----- From: "Michael Rigby-Jones" To: Sent: Tuesday, August 08, 2000 1:00 AM Subject: Re: [OT]: Using Visual Basic with RS232 Read > > Thanks Mike, > > I implemented your suggestions as best I could. It seems to work > > except > > for one glitch: If a byte value of zero is sent, the program doesn't seem > > to > > recognize it. It seems that any value from 0 to 255 should be valid. Is > > there something unique about 0 when using strings perhaps? Maybe this was > > also part of my original problem. I'm also wondering if there is a way to > > clear MSComm1.CommEvent which is read only. > > My modified code is attached. > > Thanks for the useful suggestions. > > > > Dan Mulally > > << File: lloydspc.vbw >> << File: lloydspc.vbp >> << File: lloydspc.frm > > >> > > > > > Ooops, sorry about that. This is due the the Comm control expecting ANSI > characters and Character 0 is a Null character which it dosen't like. You > can fix this by setting Comm1.InputMode = comInputModeBinary. This means > the Input method of the Comm control returns a byte array rather than a > string so your routines will have to be modified a tiny bit. > > The VB Example shows how to do this using a Variant, which I don't usualy > like using but it does make the code very simple. > > Dim Buffer as Variant > Dim bytArray() as Byte > > > ' Get the contents of the Comm buffer > > Buffer = MSComm1.Input > > 'Convert to byte array > > bytArray = Buffer > > ' Send the data to your display routine > > For intCount = LBound(bytArray) To Ubound(bytArray) > DisplayChar(bytArray(intCount)) > Next intCount > > > Hope this works, I don't have two PC's available right noe to test this. > > Cheers > > Mike > > -- > http://www.piclist.com hint: The PICList is archived three different > ways. See http://www.piclist.com/#archives for details. -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu