CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: PortOpen

  1. #1
    Join Date
    Aug 2001
    Location
    Longueuil, Canada
    Posts
    6

    PortOpen

    Hi!
    I have the following problem with my code: when it goes through MSComm1.portopen=true, there is an error message "Port already open". If I step over that line, later, when the code is MSCOmm1.output=Chr$(stx),where Const stx=&H2, the error message is "Operation valid only when the port is open".
    If I put my cursor over MScomm1.portopen, the variable is said to be False...I use the exact same code in an other form and it works very well.
    Please help me!
    Thanks


    Valérie Pepin

  2. #2
    Join Date
    Jun 1999
    Location
    Switzerland
    Posts
    398

    Re: PortOpen

    Maybe the COM port is used by another application (...or MSComm object in your app).

    Leica Geosystems - when it has to be right

  3. #3
    Join Date
    Aug 2001
    Location
    Longueuil, Canada
    Posts
    6

    Re: PortOpen

    So that means I can not use the MSComm control in 2 different forms within the same Project...?

    Valérie Pepin

  4. #4
    Join Date
    Jun 1999
    Location
    Switzerland
    Posts
    398

    Re: PortOpen

    You can do that, but you cannot open the same COM port with two
    different MSComm controls.

    Leica Geosystems - when it has to be right

  5. #5
    Join Date
    Nov 2001
    Location
    Cumbria, England, UK
    Posts
    8

    Re: PortOpen

    I dont know why it does it but i have had the same problem, It may be that we are both trying to write to the port outside a control. There is a good program at http://www.ontrak.net/visual.htm which a friend told me about and i have got this working
    good luck
    Jason


  6. #6
    Join Date
    Dec 2001
    Location
    Pennsylvania USA
    Posts
    7

    Re: PortOpen

    Unless you want to access two different serial ports at the same time, you should only have one MsComm control in your project. You may want to move this to a separate (non-visible) form which is loaded at the beginning of the program, and then not unloaded until you exit.


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured