You'll want to do something like this:
Code:Public Sub SenseCOMPorts(ByRef com_list() As Integer) On Error Resume Next Dim i As Integer Dim l_cnt As Integer Erase com_list l_cnt = -1 '' check ports 1 - 16 For i = 1 To 16 Step 1 vbCOM.CommPort = i '' set the port # vbCOM.PortOpen = True '' try to open the port '' add it to the list if it is open If (vbCOM.PortOpen) Then l_cnt = l_cnt + 1 ReDim Preserve com_list(l_cnt) As Integer com_list(l_cnt) = i End if vbCOM.PortOpen = False '' close the port Next i End Sub




Reply With Quote