COM Port 被佔去



贊助商連結


edel41
2001-07-05, 01:29 AM
我因為太懶骨頭,連「電話銀行」都用Excel 代打,目前用下列程式。
但一踫到「WinFax]之類的COM Port 就被佔去…
請 各位大大 Help !!


Public Sub Dial(Number$)
' MSComm1 need -> 工具-設定引用項目-Microsoft Comm Control 6.0 (MSCOMM32.OCX)
' 並且打開 音量控制-音源
Set Comm = 轉帳作業.MSComm1
Dim FromModem$, dummy
' Communications port settings.
' Assuming that a modem is attached to COM2, CommPort is set to 2
If Not OnLine Then
Comm.CommPort = 2
Comm.Settings = "9600,N,8,1"
' Open the communications port.
On Error Resume Next
Comm.PortOpen = True
If Err Then
MsgBox "COM2: 無法使用. 請將 CommPort 屬性改變成其他通訊埠。"
Exit Sub
End If
OnLine = True
End If
' Flush the input buffer.
Comm.InBufferCount = 0
' Dial the number.
Comm.Output = Number$ & vbCr
' Wait for "OK" to come back from the modem.
Do
dummy = DoEvents()
' If there is data in the buffer, then read it.
If Comm.InBufferCount Then
FromModem$ = FromModem$ + Comm.Input
' Check for "OK"
If InStr(FromModem$, "OK") Then Exit Do
End If
' Did the user choose Cancel?
If CancelFlag Then
' Close the port.
Comm.PortOpen = False
OnLine = False
CancelFlag = False
Exit Do
End If
Loop
End Sub

贊助商連結


edel41
2001-07-07, 02:51 PM
簡單的說,就是跟「WinFax]之類的在搶 COM Port 啦 !!