📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "S7_200_PPI 通信"
ClientHeight = 6570
ClientLeft = 60
ClientTop = 450
ClientWidth = 7155
LinkTopic = "Form1"
ScaleHeight = 6570
ScaleWidth = 7155
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text13
Height = 375
Left = 5040
TabIndex = 39
Text = "0"
Top = 5880
Width = 855
End
Begin VB.TextBox Text12
Height = 375
Left = 3480
TabIndex = 37
Text = "0"
Top = 5880
Width = 855
End
Begin VB.CommandButton Command11
Caption = "位测试"
Height = 495
Left = 1800
TabIndex = 36
Top = 5880
Width = 975
End
Begin VB.Frame Frame7
Height = 135
Left = 1800
TabIndex = 35
Top = 5640
Width = 5175
End
Begin VB.Frame Frame6
Height = 135
Left = 1800
TabIndex = 34
Top = 4800
Width = 5175
End
Begin VB.TextBox Text11
Height = 375
Left = 5040
TabIndex = 33
Text = "0"
Top = 5160
Width = 855
End
Begin VB.TextBox Text10
Height = 375
Left = 5040
TabIndex = 31
Text = "50"
Top = 4440
Width = 855
End
Begin VB.TextBox Text9
Height = 375
Left = 3480
TabIndex = 29
Text = "0"
Top = 5160
Width = 855
End
Begin VB.TextBox Text8
Height = 375
Left = 3480
TabIndex = 27
Text = "0"
Top = 4440
Width = 855
End
Begin VB.CommandButton Command10
Caption = "写VW"
Height = 495
Left = 1800
TabIndex = 25
Top = 5040
Width = 975
End
Begin VB.CommandButton Command9
Caption = "读VW"
Height = 495
Left = 1800
TabIndex = 24
Top = 4320
Width = 975
End
Begin VB.CommandButton Command8
Caption = "复位"
Height = 375
Left = 1800
TabIndex = 23
Top = 3720
Width = 975
End
Begin VB.Frame Frame4
Height = 135
Left = 1800
TabIndex = 22
Top = 4080
Width = 5175
End
Begin VB.TextBox Text7
Height = 375
Left = 5040
TabIndex = 21
Text = "0"
Top = 3600
Width = 855
End
Begin VB.TextBox Text6
Height = 375
Left = 3480
TabIndex = 19
Text = "0"
Top = 3600
Width = 855
End
Begin VB.CommandButton Command7
Caption = "置位"
Height = 375
Left = 1800
TabIndex = 17
Top = 3360
Width = 975
End
Begin VB.Frame Frame3
Height = 135
Left = 1800
TabIndex = 16
Top = 3120
Width = 5175
End
Begin VB.TextBox Text5
Height = 375
Left = 5040
TabIndex = 14
Text = "0"
Top = 2760
Width = 855
End
Begin VB.TextBox Text4
Height = 375
Left = 5040
TabIndex = 12
Text = "100"
Top = 2040
Width = 855
End
Begin VB.TextBox Text3
Height = 375
Left = 3480
TabIndex = 10
Text = "0"
Top = 2760
Width = 855
End
Begin VB.TextBox Text2
Height = 375
Left = 3480
TabIndex = 8
Text = "0"
Top = 2040
Width = 855
End
Begin VB.CommandButton Command6
Caption = "写VB"
Height = 495
Left = 1800
TabIndex = 6
Top = 2640
Width = 975
End
Begin VB.CommandButton Command5
Caption = "读VB"
Height = 495
Left = 1800
TabIndex = 5
Top = 1920
Width = 975
End
Begin VB.TextBox Text1
Height = 1695
Left = 120
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 4
Text = "Form1.frx":0000
Top = 120
Width = 6855
End
Begin VB.CommandButton Command4
Caption = "STOP"
Height = 495
Left = 240
TabIndex = 3
Top = 4080
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "RUN"
Height = 495
Left = 240
TabIndex = 2
Top = 3480
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "关闭串口"
Height = 495
Left = 240
TabIndex = 1
Top = 2640
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "打开串口"
Height = 495
Left = 240
TabIndex = 0
Top = 2040
Width = 1095
End
Begin VB.Frame Frame2
Height = 135
Left = 1800
TabIndex = 15
Top = 2400
Width = 5175
End
Begin VB.Label Label13
Caption = "(0-7)"
Height = 255
Left = 6120
TabIndex = 41
Top = 6000
Width = 615
End
Begin VB.Label Label12
Caption = "位"
Height = 255
Left = 4560
TabIndex = 40
Top = 6000
Width = 255
End
Begin VB.Label Label11
Caption = "字节数据"
Height = 495
Left = 2880
TabIndex = 38
Top = 6000
Width = 375
End
Begin VB.Label Label10
Caption = "值"
Height = 255
Left = 4560
TabIndex = 32
Top = 5280
Width = 375
End
Begin VB.Label Label9
Caption = "字数"
Height = 255
Left = 4560
TabIndex = 30
Top = 4560
Width = 495
End
Begin VB.Label Label8
Caption = "地址"
Height = 255
Left = 2880
TabIndex = 28
Top = 5280
Width = 375
End
Begin VB.Label Label7
Caption = "地址"
Height = 255
Left = 2880
TabIndex = 26
Top = 4440
Width = 375
End
Begin VB.Label Label6
Caption = "位"
Height = 255
Left = 4560
TabIndex = 20
Top = 3720
Width = 375
End
Begin VB.Label Label5
Caption = "地址"
Height = 255
Left = 2880
TabIndex = 18
Top = 3720
Width = 375
End
Begin VB.Label Label4
Caption = "值"
Height = 255
Left = 4560
TabIndex = 13
Top = 2880
Width = 375
End
Begin VB.Label Label3
Caption = "字节数"
Height = 255
Left = 4440
TabIndex = 11
Top = 2160
Width = 615
End
Begin VB.Label Label2
Caption = "地址"
Height = 255
Left = 2880
TabIndex = 9
Top = 2880
Width = 375
End
Begin VB.Label Label1
Caption = "地址"
Height = 255
Left = 2880
TabIndex = 7
Top = 2160
Width = 375
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Text1 = ""
If OpenCom(1) > 0 Then
Text1 = "打开串口"
Else
Text1 = "error"
End If
End Sub
Private Sub Command10_Click()
Text1 = ""
If writeVW(2, Val(Text9), Val(Text11)) > 0 Then
Text1 = "ok"
Else
Text1 = "error"
End If
End Sub
Private Sub Command11_Click()
If (bit(Val(Text12.Text), Val(Text13.Text))) Then
MsgBox "1"
Else
MsgBox "0"
End If
End Sub
Private Sub Command12_Click()
End Sub
Private Sub Command2_Click()
Text1 = ""
If CloseCom() Then
Text1 = "关闭"
Else
Text1 = "error"
End If
End Sub
Private Sub Command3_Click()
Text1 = ""
If PLCRUN(2) > 0 Then
Text1 = "运行"
Else
Text1 = "error"
End If
End Sub
Private Sub Command4_Click()
Text1 = ""
If PLCSTOP(2) > 0 Then
Text1 = "停止"
Else
Text1 = "error"
End If
End Sub
Private Sub Command5_Click()
Dim rxdata(1024) As Byte
Dim tmp As String
Text1 = ""
If readVB(2, Val(Text2), Val(Text4), rxdata(0)) > 0 Then
tmp = ""
For i = 0 To Val(Text4) - 1
tmp = tmp & rxdata(i) & ","
Next
Text1 = tmp
Else
Text1 = "error"
End If
End Sub
Private Sub Command6_Click()
Text1 = ""
If writeVB(2, Val(Text3), Val(Text5)) > 0 Then
Text1 = "ok"
Else
Text1 = "error"
End If
End Sub
Private Sub Command7_Click()
Text1 = ""
If bitsetV(2, 0, 0) > 0 Then '
Text1 = "ok"
Else
Text1 = "error"
End If
End Sub
Private Sub Command8_Click()
Text1 = ""
If bitResetV(2, 0, 0) > 0 Then
Text1 = "ok"
Else
Text1 = "error"
End If
End Sub
Private Sub Command9_Click()
Dim rxdata(1024) As Integer
Dim tmp As String
Text1 = ""
If readVW(2, Val(Text8), Val(Text10), rxdata(0)) > 0 Then
tmp = ""
For i = 0 To Val(Text10) - 1
tmp = tmp & rxdata(i) & ","
Next
Text1 = tmp
Else
Text1 = "error"
End If
End Sub
Private Sub Form_Load()
Command1_Click
End Sub
Private Sub Form_Unload(Cancel As Integer)
Command2_Click
End Sub
Private Sub Text12_Change()
If Val(Text12.Text) > 255 Then Text12.Text = 0
End Sub
Private Sub Text13_Change()
If Val(Text13.Text) > 7 Then Text13.Text = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -