dcsimg
Results 1 to 4 of 4

Thread: Can I replace the imported Interop 'AxMSComm' w/ 'MSComm'?

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2012
    Posts
    49

    Can I replace the imported Interop 'AxMSComm' w/ 'MSComm'?

    Hi folks,
    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:

    Public WithEvents MSComm1 As AxMSCommLib.AxMSComm

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

    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 ultimate resort is I can use System.IO.Ports.SerialPort to do the serial communication, which is the .net way to do it, which means I need to get rid of the Interop and a lot of rewrites..

    Ideas appreciated thx

  2. #2
    Addicted Member
    Join Date
    Nov 2011
    Posts
    212

    Re: Can I replace the imported Interop 'AxMSComm' w/ 'MSComm'?

    The System.IO SerialPort is the way to go. At first glance it may seem more complicated or awkward if your used to MSComm but the fact is that it is easier more reliable and more versatile. As you progress through the conversion post any snippets you need help with.

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,088

    Re: Can I replace the imported Interop 'AxMSComm' w/ 'MSComm'?

    Agreed, You should be using the serialport class, it shouldnot be to difficult to switch, depending on how you need to use it in your project.

  4. #4

    Thread Starter
    Member
    Join Date
    Mar 2012
    Posts
    49

    Re: Can I replace the imported Interop 'AxMSComm' w/ 'MSComm'?

    Yeah... well..I was thinking of making some minor changes so that the interop would work using the converted code but..what the hell..I'll study some SerialPort material.
    Thanks guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width