主题:请哪位高手帮忙改一下
Dim src As Integer
Dim he As Integer
Dim qufan As Byte
Dim gonglv As Long
Dim pinlv As Long
Dim linshi As Long
Dim linshi1 As Long
Dim linshi2 As Long
Dim gaowei As Byte
Dim diwei As Byte
Dim biaoshi As Byte
Dim qian As Integer
Dim hou As Integer
Dim jieguo As Integer
Dim zanshi As Integer
Dim jiyong As Variant
Dim fasong(1 To 4) As Byte
Private Sub Command1_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
Label12.Visible = False
Label13.Visible = False
If (Val(Text1.Text) > 10) Then
Label12.Visible = True
Label12.Caption = "数据输入有误,请重新输入"
End If
linshi = Val(Text1.Text)
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi1 = linshi
gaowei = CByte(linshi)
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi2 = linshi
diwei = CByte(Val(Text1.Text) - linshi)
he = CInt(Val(Text1.Text) - linshi + linshi1)
If (he = 0) Then
src = 0
Else
src = 256 - he
If (src < 0) Then
src = 512 - he
End If
End If
jiyong = src
qufan = CByte(jiyong)
Label11.Caption = he
Label10.Caption = qufan
biaoshi = 90
fasong(1) = biaoshi
fasong(2) = gaowei
fasong(3) = diwei
fasong(4) = qufan
Label5.Caption = fasong(2)
Label6.Caption = fasong(3)
Label7.Caption = fasong(4)
Label8.Caption = fasong(1)
MSComm1.Output = fasong
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
Label12.Visible = False
Label13.Visible = False
If ((Val(Text2.Text) < 10000) Or (Val(Text2.Text) > 12000)) Then
Label12.Visible = True
Label12.Caption = "数据输入有误,请重新输入"
End If
linshi = Val(Text2.Text)
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi1 = linshi
gaowei = CByte(linshi)
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi2 = linshi
diwei = CByte(Val(Text2.Text) - linshi)
he = CInt(Val(Text2.Text) - linshi + linshi1)
If (he = 0) Then
src = 0
Else
src = 256 - he
If (src < 0) Then
src = 512 - he
End If
End If
jiyong = src
qufan = CByte(jiyong)
Label11.Caption = he
Label10.Caption = qufan
biaoshi = 90
fasong(1) = biaoshi
fasong(2) = gaowei
fasong(3) = diwei
fasong(4) = qufan
Label5.Caption = fasong(2)
Label6.Caption = fasong(3)
Label7.Caption = fasong(4)
Label8.Caption = fasong(1)
MSComm1.Output = fasong
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeBinary
MSComm1.RThreshold = 4
MSComm1.InputLen = 0
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
jieguo = MSComm1.Input
Label13.Visible = True
Text3.Text = jieguo
If (jieguo = 255) Then
Label13 = "数据已发送成功"
End If
If (jieguo = 0) Then
Label3 = "数据发送失败"
End If
Case Else
End Select
End Sub
Dim he As Integer
Dim qufan As Byte
Dim gonglv As Long
Dim pinlv As Long
Dim linshi As Long
Dim linshi1 As Long
Dim linshi2 As Long
Dim gaowei As Byte
Dim diwei As Byte
Dim biaoshi As Byte
Dim qian As Integer
Dim hou As Integer
Dim jieguo As Integer
Dim zanshi As Integer
Dim jiyong As Variant
Dim fasong(1 To 4) As Byte
Private Sub Command1_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
Label12.Visible = False
Label13.Visible = False
If (Val(Text1.Text) > 10) Then
Label12.Visible = True
Label12.Caption = "数据输入有误,请重新输入"
End If
linshi = Val(Text1.Text)
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi1 = linshi
gaowei = CByte(linshi)
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi2 = linshi
diwei = CByte(Val(Text1.Text) - linshi)
he = CInt(Val(Text1.Text) - linshi + linshi1)
If (he = 0) Then
src = 0
Else
src = 256 - he
If (src < 0) Then
src = 512 - he
End If
End If
jiyong = src
qufan = CByte(jiyong)
Label11.Caption = he
Label10.Caption = qufan
biaoshi = 90
fasong(1) = biaoshi
fasong(2) = gaowei
fasong(3) = diwei
fasong(4) = qufan
Label5.Caption = fasong(2)
Label6.Caption = fasong(3)
Label7.Caption = fasong(4)
Label8.Caption = fasong(1)
MSComm1.Output = fasong
End Sub
Private Sub Command2_Click()
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
Label12.Visible = False
Label13.Visible = False
If ((Val(Text2.Text) < 10000) Or (Val(Text2.Text) > 12000)) Then
Label12.Visible = True
Label12.Caption = "数据输入有误,请重新输入"
End If
linshi = Val(Text2.Text)
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi = linshi \ 2
linshi1 = linshi
gaowei = CByte(linshi)
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi = linshi * 2
linshi2 = linshi
diwei = CByte(Val(Text2.Text) - linshi)
he = CInt(Val(Text2.Text) - linshi + linshi1)
If (he = 0) Then
src = 0
Else
src = 256 - he
If (src < 0) Then
src = 512 - he
End If
End If
jiyong = src
qufan = CByte(jiyong)
Label11.Caption = he
Label10.Caption = qufan
biaoshi = 90
fasong(1) = biaoshi
fasong(2) = gaowei
fasong(3) = diwei
fasong(4) = qufan
Label5.Caption = fasong(2)
Label6.Caption = fasong(3)
Label7.Caption = fasong(4)
Label8.Caption = fasong(1)
MSComm1.Output = fasong
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeBinary
MSComm1.RThreshold = 4
MSComm1.InputLen = 0
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
jieguo = MSComm1.Input
Label13.Visible = True
Text3.Text = jieguo
If (jieguo = 255) Then
Label13 = "数据已发送成功"
End If
If (jieguo = 0) Then
Label3 = "数据发送失败"
End If
Case Else
End Select
End Sub