本文介绍了通过visual basic6调制解调器自动检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码也连接调制解调器并发送消息。但我想得到正确的端口名称onmich Modem attatch,如com5。我怎么能这样做?
This code connect the Modem and send message also.But i want to get Correct port name onwhich Modem attatch such as com5.How can i do this ?
Private Sub Timer1_Timer()
Dim FromModem$
On Error Resume Next
For i% = 1 To 6
MSComm1.CommPort = i%
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
MSComm1.InBufferCount = 0
Label8.Caption = " PORT " & i%
pb1.Value = pb1.Value + 10
List2.AddItem i%
Text1.Text = "Searching Modem Port" & i%
MSComm1.Output = "AT" + Chr$(13)
Sleep 4000
If MSComm1.InBufferCount Then
FromModem$ = FromModem$ + MSComm1.Input
If InStr(FromModem$, "OK") Then
MsgBox "Modem has Found" & i%
Beep 400, 300
Timer1.Enabled = False
Exit For
End If
Else
MSComm1.PortOpen = False
End If
End If
DoEvents
Next i%
If i% > 6 Then
Timer1.Enabled = False
End If
End Sub
推荐答案
这篇关于通过visual basic6调制解调器自动检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!