|
发表于 2008-3-14 00:24:01
|
显示全部楼层
看做什么用了,只是接收保存的话用文件最最简单,而用数据库有时还是比较麻烦的,试用简单的方法,看几行能搞定?
'Code
Private Sub GetComDataToFile(Byval CommPort As Integer, Byval FileName As String, Byval WaitTime as Integer)
Dim MSComm As Object, FNumber As Integer, mTimer, mInput as String
Set MsComm = CreateObject("MSCommLib.MSComm")
FNumber = FreeFile
Open FileName For Append As FNumber
mTimer = Timer
With MsComm
.CommPort = CommPort
.PortOpen = True
Do Until (Timer - mTimer) < WaitTime
If .InBufferCount > 0 Then
mInput = .Input()
Print #FNumber , mInput;
End If
DoEvents
Loop
.PortOpen = False
End With
Set MsComm = Nothing
Close FNumber
End Sub
' Code end
对于文本方式20行左右就是一个完整的接收/保存过程了,不过这段程序是在网页上直接写的,拷贝过去运行通不过别怪我。 |
|