Re: enumerate existing comm ports
- From: "Jack" <notreplyto@it>
- Date: Mon, 30 Oct 2006 00:57:05 -0500
Your code is flawed.
On Error Resume NextWhen the port is already opened then
For x = 1 to 10
mscomm1.comPort = x
mscomm1.portOpen = true
if err <> 0 then
mscomm1.comPort = x
generates error (Port in Use)
but
mscomm1.portOpen = true
will not generate the error, thus the statement:
if err<>0
is not correct.
Jack
"DanS" <t.h.i.s.n.t.h.a.t@xxxxxxxxxxxxxxxxxxxxx> wrote in message
news:Xns986BBFC4A9201thisnthatadelphianet@xxxxxxxxxxxxxxxxx
"Jack" <notreplyto@it> wrote in news:upFHDN7#GHA.4388
@TK2MSFTNGP02.phx.gbl:
How to enumerate existing comm ports?
Jack
An easy way is to just try to open com1 thru 10 (or whatever) and trap
for errors.
On Error Resume Next
For x = 1 to 10
mscomm1.comPort = x
mscomm1.portOpen = true
if err <> 0 then
'Check for error type here
err.Clear
else
mscomm1.portOpen = false
end if
next
There will be 2 main errors, either InvalidPort or PortInUse. If there's
no error the port number is valid and available, PortInUse error means
the post is there but in use (obviously), and if you get back
InvalidPort, there is no port.
I'm sure there are other ways to do this, but in a pinch, I've always
used this.
.
- Follow-Ups:
- Re: enumerate existing comm ports
- From: DanS
- Re: enumerate existing comm ports
- References:
- enumerate existing comm ports
- From: Jack
- Re: enumerate existing comm ports
- From: DanS
- enumerate existing comm ports
- Prev by Date: Re: How to allow a specific number of Instances of my app?
- Next by Date: Re: LZW .Z Decompression?
- Previous by thread: Re: enumerate existing comm ports
- Next by thread: Re: enumerate existing comm ports
- Index(es):
Relevant Pages
|