Hi Ken, > Dim bytUART_Byte As Byte > > bytUART_Byte = CType(AxMSComm1.Input(), Byte())(0) VB.NET is now a 'true' object orientated language like java or C#. Lets break it down.. AxMSComm1.Input() returns an Object which is actually a System.Array object which is actually an array of Bytes.. If you think of it in terms of say pointers Object -> System.Array -> Byte() -- this is conceptual not literal but it should help think 'object's So if we think about what the underlying .NET Virtual Machine is doing by replacing the AxMSComm1.Input() we can see Eval 1: bytUART_Byte = CType( Object -> System.Array -> Byte() , Byte())(0) Ok. So now what Ctype( object, Type) does it to convert or cast, or really in this case traverse the pointer heirachy looking for the matching Byte() array that we are interested in so it basically trims off the Object->System.Array and just returns the Byte Array Byte() Eval 2: bytUART_Byte = Byte()(0) So now you can more easily see what the (0) is.. It is the zeroth index into the Byte Array This is equivalent to this code Dim InputObject as Object Dim InputByteArray() As Byte Dim bytUART_Byte as Byte InputObject = AxMSComm1.Input() InputByteArray = CType(AxMSComm1.Input(), Byte()) bytUART = InputByteArray(0) So to understand physically what is happening.. Say you send 'HI' on the serial connection you can imagine the Serial InputBuffer having MSComm.InputBuffer = {'H','I'} Now because you are settings are to read only a single byte at a time, executing AxMSComm1.Input() returns only a single element array, and leaves the other byte in the InputBuffer for next time -- InputObject = AxMSComm1.Input() MSComm.InputBuffer = {'I'} InputObject = Object->System.Array->ByteArray->{'H'} -- So now you only have an Object reference but you want to get access to the ByteArray so this is where you you CType InputByteArray = CType(AxMSComm1.Input(), Byte()) Which gives InputByteArray = Byte(){'H'} -- So Finally you want to get the first ( and only ) element from this array and keep it as bytUART_Byte byteUART = InputByteArray(0) Which gives byteUART = 72 ' 'H' = 72 Hope this helps :-) Cheers, James Caska www.muvium.com uVM - 'Java Bred for Embedded' -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of Ken Pergola Sent: Friday, October 01, 2004 9:40 PM To: Microcontroller discussion list - Public. Subject: RE: [EE] Serial port control under VB.NET 2002/2003 James Caska wrote: > If you have Strict Mode on then you will need to explicitly cast the > Input to a Byte Array. I think someone said something like this earlier also. > > > Dim bytUART_Byte As Byte > > bytUART_Byte = CType(AxMSComm1.Input(), Byte())(0) Hi James, Thanks kindly James -- yes that's it. I don't quite understand it yet, but I'll have to research the CType and read up on it. The '(0)' suffix gives me a buzz cut -- not sure what that is doing. Any chance you can point me to a link that describes that? In any event, the simple project showing how to use the MSCOMM control in BINARY mode under VB.NET works. Thanks to all who helped me out to convert the simple demo MSCOMM project to VB.NET. We have thread closure. I wanted to post the zip file of the VB.NET project in this post for the benefit of anyone who is interested, but the file size is 54 kilobytes -- rather large for the PICList -- I don't want to upset anyone, but if the PICList administrators say it's ok, I'll post it as an e-mail attachment. Thanks for everyone's help and time. You all are very kind -- and patient! Much obliged, Ken Pergola _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist