发表于:2006-01-13 16:48:00
楼主
下面是我编的程序,可在运行的时候确读不出数据,请个位高手告诉我吧!这是我第一次编的!Option Explicit
Private Sub Command1_Click()
MSComm1.PortOpen = True
End Sub
Private Sub MSComm1_OnComm()
Dim strErrDescription As String '错误信息
Dim blnPortOpen As Boolean '设置并返回通讯端口的状态(开或关)。在设计时无效。
Dim bytCommPort As Byte '通讯端口号 1-16
Dim varTimer As Date
Dim bytBW500ID1(7) As Byte 'BW500ID1皮带称Rate Load Speed Total1
Dim bytBW500ID2(7) As Byte 'BW500ID2皮带称Rate Load Speed Total1
Dim bytBW500ID3(7) As Byte 'BW500ID3皮带称Rate Load Speed Total1
Dim bytBW500ID4(7) As Byte 'BW500ID4皮带称Rate Load Speed Total1
Public Event BW500ReadCompleted(ByVal itbeltID As Integer, ByVal strRate As String, ByVal strLoad As String, ByVal strSpeed As String, ByVal strTotal1 As String)
Public Event BW500ReadDisCompleted(ByVal itbeltID As Integer)
Dim bolBw500Debug As Boolean
Dim bolBw500Debug1 As Boolean
'皮带称读取
Public Function BW500Id(ByVal intTBeltID As Integer)
On Error Resume Next
Dim intBeltID As Integer
Dim i%, Buf$
Dim strTemp As String
Dim strTempRate As String, strTempLoad As String, strTempSpeed As String, strTempTotal1 As String
Dim Buffer() As Byte
With MSComm
If blnPortOpen = True Then
.OutBufferCount = 0
.InBufferCount = 0
Select Case intTBeltID
Case 1:
.Output = bytBW500ID1
Case 2:
.Output = bytBW500ID2
Case 3:
.Output = bytBW500ID3
Case 4:
.Output = bytBW500ID4
End Select
varTimer = Now
Do
DoEvents
&nbs