Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modem question 1

Status
Not open for further replies.

scrano

Technical User
Jan 24, 2001
51
0
0
AU
Can anyone please tell me if it is possible to check through VB whether someone has a modem installed and what com port it's using and things like that? Thanx in advance
 
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 & &quot;\Phone.bmp&quot;)
StatusBar1.Panels(4).Text = &quot;Modem Available on port : &quot; & Str(WitchComm(DIALER))

Else

StatusBar1.Panels(4).Text = &quot;Modem not Avialable&quot;

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 = &quot;9600,N,8,1&quot;
MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)
x = 1


Do: DoEvents
x = x + 1
If x = 1000 Then MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)
If x = 2000 Then MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)
If x = 3000 Then MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)
If x = 4000 Then MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)
If x = 5000 Then MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)
If x = 6000 Then MyForm.MSComm1.Output = &quot;AT&quot; + Chr$(13)


If x = 7000 Then
MyForm.MSComm1.PortOpen = False
Port = Port + 1
GoTo PortinG:


If MyForm.MSComm1.CommPort >= 5 Then
errr:
' MsgBox &quot;Can't Find Modem!&quot;
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 &quot;Modem Found On Comm&quot; & Port
WitchComm = Port

done:

End Function
 
Thanx for that. Do you know whether there's is an API call or something like that, that will return the name of all modems installed so you can actually pick between them? Thanx in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top