-1
我有一些電腦調制解調器和其他沒有使用相同的數據庫。他們需要確定是否安裝了調制解調器。我在互聯網上發現由KHaled El-Menshawy創建的代碼,它有可能做我想做的事情,但我得到一個「Object required」錯誤。我認爲這是一個簡單的解決方法,但我不知道應該如何聲明這個對象。任何人都可以找出丟失的代碼?這裏是他的代碼:檢查調制解調器
Public Function CheckModem()
On Error GoTo Errr
If ProgBar.Value = 100 Then
ProgBar.Value = 0
End If
Port = 1
PortinG:
MSComm1.CommPort = Port
MSComm1.PortOpen = True
ProgBar.Value = ProgBar.Value + 20
Label1.Caption = ProgBar.Value & "%"
Form1.MSComm1.Settings = "9600,N,8,1"
MSComm1.Output = "AT" + Chr$(13)
X = 1
Do: DoEvents
X = X + 1
If X = 1000 Then MSComm1.Output = "AT" + Chr$(13)
If X = 2000 Then MSComm1.Output = "AT" + Chr$(13)
If X = 3000 Then MSComm1.Output = "AT" + Chr$(13)
If X = 4000 Then MSComm1.Output = "AT" + Chr$(13)
If X = 5000 Then MSComm1.Output = "AT" + Chr$(13)
If X = 6000 Then MSComm1.Output = "AT" + Chr$(13)
If X = 7000 Then
MSComm1.PortOpen = False
Port = Port + 1
GoTo PortinG:
If MSComm1.CommPort >= 6 Then
Errr:
MsgBox "Can't Find Modem"
GoTo done
End If
End If
Loop Until MSComm1.InBufferCount >= 2
instring = MSComm1.Input
MSComm1.PortOpen = False
ProgBar.Value = 100
Label1.Caption = ProgBar.Value & "%"
Text1.Text = "com" & Port 'MSComm1.CommPort & instring
MsgBox "Modem found On Com" & Port
done:
End Function
'MSComm1'從哪裏來? – serakfalcon
我不知道MSComm1從哪裏來。此代碼超出了我的VBA體驗。我希望在工作時插入它,然後弄清它是如何工作的。我瞭解端口和「AT」代碼,但不知道如何回答你的問題。它看起來像一些聲明丟失。任何想法如何使這項工作? – Rod