📄 form2.frm
字号:
VERSION 5.00
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 4800
ClientLeft = 60
ClientTop = 450
ClientWidth = 10635
LinkTopic = "Form2"
ScaleHeight = 4800
ScaleWidth = 10635
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text5
Height = 375
Left = 5880
TabIndex = 10
Text = "Text5"
Top = 3960
Width = 2175
End
Begin VB.TextBox Text4
Height = 375
Left = 600
TabIndex = 9
Text = "Text4"
Top = 3960
Width = 2535
End
Begin VB.CommandButton Command5
Caption = "转化十进制"
Height = 375
Left = 3240
TabIndex = 8
Top = 3960
Width = 2535
End
Begin VB.CommandButton Command4
Caption = "写数"
Height = 375
Left = 7800
TabIndex = 6
Top = 720
Width = 2535
End
Begin VB.CommandButton Command3
Caption = "读数"
Height = 375
Left = 600
TabIndex = 5
Top = 720
Width = 2535
End
Begin VB.CommandButton Command2
Caption = "通信连接"
Height = 615
Left = 1800
TabIndex = 4
Top = 0
Width = 1815
End
Begin VB.TextBox Text3
Height = 495
Left = 600
TabIndex = 3
Text = "Text3"
Top = 2760
Width = 9735
End
Begin VB.TextBox Text2
Height = 495
Left = 7800
TabIndex = 2
Text = "@011W02500,0001:"
Top = 1200
Width = 2535
End
Begin VB.TextBox Text1
Height = 495
Left = 600
TabIndex = 1
Text = "@011R01000:"
Top = 1200
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "打开端口"
Height = 615
Left = 0
TabIndex = 0
Top = 0
Width = 1815
End
Begin VB.Label Label1
Caption = "返回数据"
Height = 375
Left = 600
TabIndex = 7
Top = 2280
Width = 1335
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Form1.MSComm1.InputLen = 0 '控制器
Form1.MSComm1.InBufferCount = 0
Form1.MSComm1.OutBufferCount = 0
Form1.MSComm1.InputMode = comInputModeText
If Form1.MSComm1.PortOpen = False Then
Form1.MSComm1.PortOpen = True
If Err Then
MsgBox "1串口通讯无效"
Exit Sub
End If
End If
End Sub
Private Sub Command2_Click()
Form1.MSComm1.Output = "@011W018C0,0001:" & Chr(&HD) '控制器
Sleep 1000
Text3.Text = Form1.MSComm1.Input
Sleep 1000
End Sub
Private Sub Command3_Click()
Form1.MSComm1.OutBufferCount = 0
Form1.MSComm1.Output = Text1.Text & Chr(&HD)
Sleep 1000
Text3.Text = Form1.MSComm1.Input
End Sub
Private Sub Command4_Click()
Form1.MSComm1.OutBufferCount = 0
Form1.MSComm1.Output = Text2.Text & Chr(&HD) '控制器FP23
Sleep 1000
Text3.Text = Form1.MSComm1.Input
End Sub
Private Sub Command5_Click()
Text5.Text = Val("&H" & Text4.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -