网上找的代码粘贴到VB6里面出错 请版主看一下哪儿出错
VERSION 5.00
Begin VB.Form frmMain
Caption = "宇电519仪表通讯"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin cmdRead
Caption = "读取数据"
Height = 495
Left = 1680
TabIndex = 2
Top = 2160
Width = 1215
End
Begin VB.TextBox txtSetpoint
Height = 375
Left = 1680
Locked = -1 'True
TabIndex = 1
Top = 1200
Width = 1215
End
Begin VB.TextBox txtDisplay
Height = 375
Left = 1680
Locked = -1 'True
TabIndex = 0
Top = 600
Width = 1215
End
Begin VB.Label Label2
Caption = "设定值:"
Height = 255
Left = 840
TabIndex = 4
Top = 1320
Width = 735
End
Begin VB.Label Label1
Caption = "显示值:"
Height = 255
Left = 840
TabIndex = 3
Top = 720
Width = 735
End
Begin MSCommLib.MSComm MSComm1
Left = 3600
Top = 240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
CommPort = 1
DTREnable = -1 'True
RThreshold = 1
RTSEnable = -1 'True
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdRead_Click()
' 初始化串口
With MSComm1
.Settings = "9600,n,8,1" ' 宇电519默认通讯参数
.PortOpen = True
End With
' 读取显示值
txtDisplay.Text = Format(ReadDisplayValue(MSComm1), "0.00")
' 读取设定值
txtSetpoint.Text = Format(ReadSetpoint(MSComm1), "0.00")
' 关闭串口
MSComm1.PortOpen = False
End Sub