VB编写串口程序,如何检测计算机有几个COM口?10
发布网友
发布时间:2023-10-30 20:50
我来回答
共1个回答
热心网友
时间:2024-11-26 11:40
Dim i, j As Integer
Private Sub Command1_Click()
j = 0
For i = 1 To 16
MSComm1.CommPort = i
On Error Resume Next
MSComm1.PortOpen = True
If Err.Number = 0 Then
j = j + 1
Else
MSComm1.PortOpen = False
End If
Next i
Label1.Caption = "您计算机上有: " & j & "个"
End Sub