COM open/close problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill

    COM open/close problem

    the following code works most of the time, but sometimes it fails.
    Anyone got an idea? It will pass the IF statement (port is open) but
    fail to set the port closed.

    If MSComm1.PortOpe n Then
    MSComm1.PortOpe n = False
    End If

    It also fails in the other direction.

    If Not MSComm1.PortOpe n Then
    MSComm1.PortOpe n = True
    End If
  • CajunCoiler \(http://www.cajuncoiler.tk\)

    #2
    Re: COM open/close problem

    Have you checked to assure that the .CommPort value hasn't
    been accidentally changed? If it has, you're closing the
    wrong port. :)

    "Bill" <wishonb@hotmai l.com> wrote in message
    news:eeb04a33.0 307091310.454a6 892@posting.goo gle.com...[color=blue]
    > the following code works most of the time, but sometimes it fails.
    > Anyone got an idea? It will pass the IF statement (port is open) but
    > fail to set the port closed.
    >
    > If MSComm1.PortOpe n Then
    > MSComm1.PortOpe n = False
    > End If
    >
    > It also fails in the other direction.
    >
    > If Not MSComm1.PortOpe n Then
    > MSComm1.PortOpe n = True
    > End If[/color]


    Comment

    • Bill

      #3
      Re: COM open/close problem

      I'm not sure how the .CommPort could change between the IF statement
      and the assignment statement. In addition, when it fails, I can hover
      over the variable and it tells me that the port is open (in the first
      case) or closed (2nd case), so the assignment statement should work,
      but still fails.

      If my memory is correct, I have even set the program back to the IF
      statement and reexecuted the lines and it still passes the IF
      statement but still fails the assignment statement.

      "CajunCoile r \(http://www.cajuncoiler .tk\)" <cajuncoiler@to tallyspamless.c ox.net> wrote in message news:<V8fPa.553 $N%3.372@lakere ad01>...[color=blue]
      > Have you checked to assure that the .CommPort value hasn't
      > been accidentally changed? If it has, you're closing the
      > wrong port. :)
      >
      > "Bill" <wishonb@hotmai l.com> wrote in message
      > news:eeb04a33.0 307091310.454a6 892@posting.goo gle.com...[color=green]
      > > the following code works most of the time, but sometimes it fails.
      > > Anyone got an idea? It will pass the IF statement (port is open) but
      > > fail to set the port closed.
      > >
      > > If MSComm1.PortOpe n Then
      > > MSComm1.PortOpe n = False
      > > End If
      > >
      > > It also fails in the other direction.
      > >
      > > If Not MSComm1.PortOpe n Then
      > > MSComm1.PortOpe n = True
      > > End If[/color][/color]

      Comment

      Working...