cdholding image

comm32 home
comm32 forum
buy comm32

Introduction
Install Comm32
Why Not MsComm?

Properties
   .Break
   .CDHolding
   .CommEvent
   .CommPort
   .CTSHolding
   .DSRHolding
   .DTREnable
   .EOFEnable
   .Handshaking
   .InBufferCount
   .InBufferSize
   .Input
   .InputLen
   .InputMode
   .NullDiscard
   .OutBufferCount
   .OutBufferSize
   .OutPut
   .ParityReplace
   .PortOpen
   .RThreshold
   .RTSEnable
   .Settings
   .STHreshold


Comm32 Properties
   .DeviceName
   .EOFChar
   .EvtChar
   .EvtCharEnable
   .OutPutEx
   .OutPutMode
   .ParallelEnable
   .TxTimeout

Comm32 Functions
   .getByte

   .GetPortStatus
   .InstalledDrivers
   .putByte
   .PortExists
   .ReadBytes
   .ReadString
   .WriteBytes
   .WriteString

OnComm Event
Hardware/Cables etc

PortExists

Retrieves a boolean True/False indicating if a given port exists

ReadOnly at Runtime.

Only available using the Comm32 ocx. Not supported by MSComm32

         Syntax result = object.PortExists(value)
     
  object Name of the communications control.
  value Numerical Com port number in the range 1 to 256
  result A Boolean - PortExists True or False
     
  Examples  
   

If Comm1.PortExists(5) Then
     MsgBox("Com5 exists")
  Else
     MsgBox("Com5 does not exist")
End If

'// Does Com5 exist ?
       
 

Remarks:
The only way that Micorosoft's MSComm32 ocx can check if a port exists is by attempting to open it and handling the error if the port doesn't exist. This new Comm32 control allows you to check whether a port exists without touching the port - This is a 'non-intrusive' read-only test meaning you can even do this if the port is busy.

Note that you do not need to change the .CommPort property - Simply pass the desired port number in the function call as shown in this example:-

'// We're going to populate a listbox with the short "Com" names of com ports that are known to exist.

Private Sub PopulateList( )
Dim i as Long

       List1.Clear
       
'// In this example we'll test for ports up to 32 - you can test up to 256 if you want.
       For i = 1 To 32
              If Comm1.PortExists( i ) = True Then
                     '// This port exists so add it to the list
                     List1.AddItem "Com" & i
                  Else
                     '// This port does not exist
              End If
       Next i
 
End Sub

 

See also DeviceName and InstalledDrivers properties.

 

 

Copyright (c) 2010 Axis Controls Ltd