📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "G&G天平采集软件"
ClientHeight = 5355
ClientLeft = 165
ClientTop = 450
ClientWidth = 7440
LinkTopic = "Form1"
ScaleHeight = 5355
ScaleWidth = 7440
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command6
Caption = "手动采集"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 1680
TabIndex = 7
Top = 600
Width = 1245
End
Begin VB.CommandButton Command5
Caption = "自动采集"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3840
TabIndex = 6
Top = 600
Width = 1245
End
Begin MSCommLib.MSComm MSComm1
Left = 360
Top = 570
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
CommPort = 2
DTREnable = -1 'True
BaudRate = 600
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 5000
Left = 5640
Top = 3840
End
Begin VB.CommandButton Command4
Caption = "计数"
Height = 495
Left = 3600
TabIndex = 4
Top = 3360
Width = 1005
End
Begin VB.CommandButton Command3
Caption = "单位转换"
Height = 465
Left = 1800
TabIndex = 3
Top = 3360
Width = 1035
End
Begin VB.CommandButton Command2
Caption = "去皮"
Height = 435
Left = 3600
TabIndex = 2
Top = 4080
Width = 1035
End
Begin VB.CommandButton Command1
Caption = "校正"
Height = 435
Left = 1800
TabIndex = 1
Top = 4080
Width = 1035
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "g"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 465
Left = 5880
TabIndex = 5
Top = 2040
Width = 915
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H00C0FFC0&
BorderStyle = 1 'Fixed Single
Caption = "-1000.000"
BeginProperty Font
Name = "宋体"
Size = 48
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 1125
Left = 1080
TabIndex = 0
Top = 1680
Width = 4545
End
Begin VB.Menu COM
Caption = "设置"
NegotiatePosition= 1 'Left
End
Begin VB.Menu EXIT
Caption = "退出"
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim a As String
Dim flag1 As Integer
Dim flag2 As Integer
Dim I
Private Sub COM_Click()
flag1 = 1: flag2 = 1
Timer1.Enabled = False
Form2.Show
End Sub
Private Sub Command1_Click()
flag1 = 1: flag2 = 1
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr$(27) + "q"
MSComm1.PortOpen = False
End Sub
Private Sub Command2_Click()
flag1 = 1: flag2 = 1
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr$(27) + "t"
MSComm1.PortOpen = False
End Sub
Private Sub Command3_Click()
flag1 = 1: flag2 = 1
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr$(27) + "s"
MSComm1.PortOpen = False
End Sub
Private Sub Command4_Click()
flag1 = 1: flag2 = 1
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr$(27) + "r"
MSComm1.PortOpen = False
End Sub
Private Sub Command5_Click()
flag1 = 1
flag2 = 0
Timer1.Enabled = True
End Sub
Private Sub Command6_Click()
flag2 = 1
flag1 = 0
Timer1.Enabled = False
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr$(27) + "p"
Do
DoEvents
If flag1 = 1 Then GoTo 10
Loop Until MSComm1.InBufferCount >= 13
a = MSComm1.Input
Label1.Caption = Mid(a, 1, 9)
Label2.Caption = Mid(a, 10, 3)
10: If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End Sub
Private Sub EXIT_Click()
flag1 = 1
flag2 = 1
Timer1.Enabled = False
Unload Form1
End Sub
Private Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "600,n,8,1"
Timer1.Interval = 2000
End Sub
Private Sub Timer1_Timer()
flag2 = 0
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
MSComm1.Output = Chr$(27) + "p"
Do
DoEvents
If flag2 = 1 Then GoTo 20
Loop Until MSComm1.InBufferCount >= 13
a = MSComm1.Input
Label1.Caption = Mid(a, 1, 9)
Label2.Caption = Mid(a, 10, 3)
20: If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -