Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Aug 21st, 2004 07:20 AM Post subject: Detect Modem Comm Port |
|
|
Preprations:
Add MSComm Control (MSComm1)
Add a Text Box (Text1)
Add a Command Button (Command1)
Add the following code to the command button named Command1.
[vb:1:fab055184d]On Error Resume Next
For i% = 1 To 16
Text1.Text = "Scanning Port " & i%
MSComm1.CommPort = i% 'Set Comm port To I%
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True 'open comm port
MSComm1.Output = "AT" + Chr$(13) ' Sends "attention" command To the modem
DoEvents 'just incase
If MSComm1.InBufferCount >= 2 Then Exit For 'once "OK" is read, exit Loop
MSComm1.PortOpen = False 'close port
End If
Next i%
If i% = 17 Then
Text1.Text = "Modem Not detected or In use."
Else
MSComm1.PortOpen = False 'close port
Text1.Text = "Your modem comm port is " & i% & "."
End If
End Sub[/vb:1:fab055184d] _________________ Code Snippets, Tutorials, Utilities, Controls
Low cost Web Hosting
Hosting starts at as low as $4 per year!
Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags! |
|