Hi , this is an example to check if modem is available and on which port is connected , hope this code would answer your question
<-----------
If WitchComm(DIALER) > 0 Then
StatusBar1.Panels(4).Picture = LoadPicture(App.Path & "\Phone.bmp"

StatusBar1.Panels(4).Text = "Modem Available on port : " & Str(WitchComm(DIALER))
Else
StatusBar1.Panels(4).Text = "Modem not Avialable"
End If
Function WitchComm(MyForm As DIALER) As Integer
Dim Port, x As Integer
Dim instring As String
On Error GoTo errr:
Port = 1
PortinG:
MyForm.MSComm1.CommPort = Port
MyForm.MSComm1.PortOpen = True
MyForm.MSComm1.Settings = "9600,N,8,1"
MyForm.MSComm1.Output = "AT" + Chr$(13)
x = 1
Do: DoEvents
x = x + 1
If x = 1000 Then MyForm.MSComm1.Output = "AT" + Chr$(13)
If x = 2000 Then MyForm.MSComm1.Output = "AT" + Chr$(13)
If x = 3000 Then MyForm.MSComm1.Output = "AT" + Chr$(13)
If x = 4000 Then MyForm.MSComm1.Output = "AT" + Chr$(13)
If x = 5000 Then MyForm.MSComm1.Output = "AT" + Chr$(13)
If x = 6000 Then MyForm.MSComm1.Output = "AT" + Chr$(13)
If x = 7000 Then
MyForm.MSComm1.PortOpen = False
Port = Port + 1
GoTo PortinG:
If MyForm.MSComm1.CommPort >= 5 Then
errr:
' MsgBox "Can't Find Modem!"
GoTo done:
End If
End If
Loop Until MyForm.MSComm1.InBufferCount >= 2
instring = MyForm.MSComm1.Input
MyForm.MSComm1.PortOpen = False
' Text1.Text = myform.MSComm1.CommPort & instring
' MsgBox "Modem Found On Comm" & Port
WitchComm = Port
done:
End Function