📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
BackColor = &H00C0FFFF&
Caption = "S7-200自由口通讯测试"
ClientHeight = 3495
ClientLeft = 60
ClientTop = 750
ClientWidth = 5760
Icon = "Form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3495
ScaleWidth = 5760
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command5
Caption = "Q 状态"
Height = 375
Left = 3480
TabIndex = 24
Top = 2760
Width = 855
End
Begin VB.CommandButton Command4
Caption = "I 状态"
Height = 375
Left = 2520
TabIndex = 23
Top = 2760
Width = 855
End
Begin VB.TextBox Text10
Appearance = 0 'Flat
Height = 270
Left = 4560
TabIndex = 22
Text = "Text10"
Top = 120
Width = 855
End
Begin VB.TextBox Text9
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 360
TabIndex = 16
Text = "Text9"
Top = 2160
Width = 855
End
Begin VB.TextBox Text8
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 1800
TabIndex = 15
Text = "Text8"
Top = 2160
Width = 855
End
Begin VB.TextBox Text7
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 3240
TabIndex = 14
Text = "Text7"
Top = 2160
Width = 855
End
Begin VB.TextBox Text6
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 4560
TabIndex = 13
Text = "Text6"
Top = 2160
Width = 855
End
Begin VB.TextBox Text5
Appearance = 0 'Flat
ForeColor = &H000000FF&
Height = 270
Left = 360
ScrollBars = 2 'Vertical
TabIndex = 12
Text = "Text5"
Top = 480
Width = 5055
End
Begin VB.Timer Timer1
Left = 0
Top = 3120
End
Begin VB.CommandButton Command3
Caption = "Command3"
Height = 375
Left = 240
TabIndex = 11
Top = 2760
Width = 975
End
Begin VB.TextBox Text4
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 4560
TabIndex = 9
Text = "Text4"
Top = 1320
Width = 855
End
Begin VB.TextBox Text3
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 3240
TabIndex = 8
Text = "Text3"
Top = 1320
Width = 855
End
Begin MSCommLib.MSComm MSComm1
Left = 2400
Top = -120
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InputMode = 1
End
Begin VB.Timer Timer2
Left = 360
Top = 3120
End
Begin VB.TextBox Text2
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 1800
TabIndex = 6
Text = "Text2"
Top = 1320
Width = 855
End
Begin VB.CommandButton Command2
Caption = "退出程序"
Height = 375
Left = 4560
TabIndex = 4
Top = 2760
Width = 975
End
Begin VB.CommandButton Command1
Caption = "开始监控"
Height = 375
Left = 1440
TabIndex = 3
Top = 2760
Width = 975
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
ForeColor = &H00FF0000&
Height = 270
Left = 360
TabIndex = 1
Text = "Text1"
Top = 1320
Width = 855
End
Begin VB.Label Label11
BackColor = &H00C0FFFF&
Caption = "通讯计时"
Height = 255
Left = 3600
TabIndex = 21
Top = 160
Width = 735
End
Begin VB.Label Label10
BackColor = &H00C0FFFF&
Caption = "I0.0状态"
Height = 255
Left = 360
TabIndex = 20
Top = 1800
Width = 855
End
Begin VB.Label Label9
BackColor = &H00C0FFFF&
Caption = "I 0.1状态"
Height = 255
Left = 1800
TabIndex = 19
Top = 1800
Width = 855
End
Begin VB.Label Label8
BackColor = &H00C0FFFF&
Caption = "Q 0.1状态"
Height = 255
Left = 4520
TabIndex = 18
Top = 1800
Width = 975
End
Begin VB.Label Label7
BackColor = &H00C0FFFF&
Caption = "Q 0.0状态"
Height = 255
Left = 3240
TabIndex = 17
Top = 1800
Width = 855
End
Begin VB.Label Label4
BackColor = &H00C0FFFF&
Caption = "模拟量 C"
Height = 255
Left = 3240
TabIndex = 10
Top = 960
Width = 735
End
Begin VB.Label Label5
BackColor = &H00C0FFFF&
Caption = "模拟量 D"
Height = 255
Left = 4560
TabIndex = 7
Top = 960
Width = 735
End
Begin VB.Label Label3
BackColor = &H00C0FFFF&
Caption = "模拟量 B"
Height = 255
Left = 1800
TabIndex = 5
Top = 960
Width = 735
End
Begin VB.Label Label2
BackColor = &H00C0FFFF&
Caption = "模拟量 A"
Height = 255
Left = 360
TabIndex = 2
Top = 960
Width = 735
End
Begin VB.Label Label1
BackColor = &H00C0FFFF&
Caption = "S7-200自由口通讯测试程序"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 0
Top = 120
Width = 3375
End
Begin VB.Menu About
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
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim x1
Dim p11, p12, p13, p14, p15, p16, p17, p18
Dim p21, p22, p23, p24, p25, p26, p27, p28
Dim a11, b11, c11, d11
Dim p31, p32, p33, p34, p35, p36, p37, p38
Dim i00, i01, q00, q01
Function FCS(ByVal InputStr As String) As String
Dim Slen, i, Xorresult As Integer
Dim Tempfes As String
Slen = Len(InputStr) '求输入字符串长度
Xorresult = 0
For i = 1 To Slen
Xorresult = Xorresult Xor Asc(Mid$(InputStr, i, 1)) '按位异或
Next i
Tempfes = Hex$(Xorresult) '转化为16进制
If Len(Tempfes) = 1 Then Tempfes = "0" + Tempfes
FCS = Tempfes
End Function
Private Sub About_Click()
frmAbout.Show
End Sub
Private Sub Form_Load() '初始化
Timer1.Enabled = False '定时器1无效
Timer1.Interval = 1000 '定时器1时间为1S
Timer2.Enabled = True '定时器2有效
Timer2.Interval = 1000 '定时器2时间为1S
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text8.Text = ""
Text10.Text = ""
MSComm1.CommPort = 1 '设定端口号
MSComm1.Settings = "9600,n,8,1" '设定通讯波特率
MSComm1.InBufferSize = 1024 '接收缓冲器大小
MSComm1.OutBufferSize = 1024 '输出缓冲器大小
MSComm1.InputMode = comInputModeBinary '以二进制传输
MSComm1.RThreshold = 21 '
MSComm1.SThreshold = 0
MSComm1.InputLen = 0 '读取接收缓冲器所有字符
MSComm1.OutBufferCount = 0 '清空发送缓冲区
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -