Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Detect Modem Comm Port
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 21st, 2004 07:20 AM    Post subject: Detect Modem Comm Port Reply with quote

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!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic