Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys
I'm porting a program from vb6 and it used the old MSComm class to do some serial communication. As some of you know, when ActiveX controls are upgraded there's a prefix "Ax-" added to the class name. So now in the Main Menu. Designer.vb the definition for the serial comm control becomes:

VB
Public WithEvents MSComm1 As AxMSCommLib.AxMSComm


later I'm having some errors (Exception from HRESULT: 0x800A017C (CTL_E_INVALIDPROPERTYVALUE)) on the line
VB
frmMainMenu.MSComm1.Output = Chr(FrameSize)


which I believe there's something wrong with the type of the right side of the equation. but that's not my biggest concern now.
I'm just wondering, can I replace this interop AxMSComm with the MSComm which I saw in the Object Browser in VB08? Will that get rid of the whole interop deal?

I guess my last resort is to use System.IO.Ports.SerialPort to do the serial communication, which is the .net way, which means I need to get rid of the Interop and a lot of rewrites..
Any ideas appreciated
--------------
ok.. I think between figuring out a way to wrestle with the interop and rewriting the code using IO.Ports.Serialport , i'd have to choose
Posted
Updated 26-Jun-12 8:47am
v2
Comments
[no name] 26-Jun-12 14:36pm    
Your "last" resort should be your first resort.

1 solution

I guess my last resort is to use System.IO.Ports.SerialPort to do the serial communication, which is the .net way, which means I need to get rid of the Interop and a lot of rewrites..

That's the answer. Don't depend on the old VB6 ways of doing things. Eventually, VB6 runtime support is going to die a justifiably horrible death.


But, you can't send a Chr character. You have to convert it to a String before you can send it to Output.
 
Share this answer
 
v2
Comments
SandiegoSSD 26-Jun-12 14:55pm    
not sure..i think it should be Bytes
Dave Kreskowiak 26-Jun-12 16:57pm    
It can be either a String or a an array of bytes, Byte(), but it has to be one of them.
SandiegoSSD 26-Jun-12 18:03pm    
yes.. when inputmode set to be binary then it's bytes. and when set to text then it's string

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900