📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4515
ClientLeft = 60
ClientTop = 450
ClientWidth = 6720
LinkTopic = "Form1"
ScaleHeight = 4515
ScaleWidth = 6720
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text7
Height = 495
Left = 1920
TabIndex = 22
Text = "Text7"
Top = 1920
Width = 1215
End
Begin VB.TextBox Text6
Height = 495
Left = 1920
TabIndex = 21
Text = "Text6"
Top = 960
Width = 1215
End
Begin VB.CommandButton Command7
Caption = "写入"
Height = 375
Left = 5880
TabIndex = 18
Top = 2520
Width = 735
End
Begin VB.TextBox Text5
Height = 375
Left = 4440
TabIndex = 15
Text = "0"
Top = 2520
Width = 1215
End
Begin VB.TextBox Text4
Height = 375
Left = 4440
TabIndex = 14
Text = "0"
Top = 1800
Width = 1215
End
Begin VB.TextBox Text3
Height = 495
Left = 120
TabIndex = 13
Text = "Text3"
Top = 1920
Width = 1455
End
Begin VB.TextBox Text2
Height = 495
Left = 1320
TabIndex = 11
Text = "Text2"
Top = 2520
Width = 1455
End
Begin VB.CommandButton Command6
Caption = "Y后退"
Height = 495
Left = 4560
TabIndex = 9
Top = 3960
Width = 855
End
Begin VB.CommandButton Command5
Caption = "Y前进"
Height = 495
Left = 3240
TabIndex = 8
Top = 3960
Width = 975
End
Begin VB.CommandButton Command4
Caption = "X后退"
Height = 495
Left = 4560
TabIndex = 7
Top = 3360
Width = 855
End
Begin VB.CommandButton Command3
Caption = "X前进"
Height = 495
Left = 3240
TabIndex = 6
Top = 3360
Width = 975
End
Begin VB.TextBox Text1
Height = 495
Left = 120
TabIndex = 4
Top = 960
Width = 1335
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
ItemData = "Form1.frx":0000
Left = 3960
List = "Form1.frx":0007
TabIndex = 2
Text = "1"
Top = 720
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "stop"
Height = 495
Left = 1200
TabIndex = 1
Top = 3600
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "start"
Height = 495
Left = 120
TabIndex = 0
Top = 3600
Width = 975
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 1920
Top = 120
End
Begin VB.Label Label7
Caption = "Y当前速度"
Height = 375
Left = 2040
TabIndex = 20
Top = 1560
Width = 1095
End
Begin VB.Label Label6
Caption = "X当前速度"
Height = 255
Left = 2040
TabIndex = 19
Top = 720
Width = 1095
End
Begin VB.Label Label5
Caption = "Y SPEED"
Height = 495
Index = 1
Left = 3480
TabIndex = 17
Top = 2640
Width = 975
End
Begin VB.Label Label5
Caption = "X SPEED"
Height = 495
Index = 0
Left = 3480
TabIndex = 16
Top = 1920
Width = 975
End
Begin VB.Label Label4
Caption = "Y轴当前位置 D130"
Height = 255
Left = 120
TabIndex = 12
Top = 1560
Width = 1575
End
Begin VB.Label Label3
Caption = "操作状态"
Height = 375
Left = 240
TabIndex = 10
Top = 2640
Width = 855
End
Begin VB.Label Label2
Caption = "X当前位置 D128"
Height = 375
Left = 120
TabIndex = 5
Top = 720
Width = 1695
End
Begin VB.Label Label1
Caption = "选择串口号"
Height = 375
Left = 4080
TabIndex = 3
Top = 360
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Change()
End Sub
Private Sub Combo1_Click()
Dim prot As String
Port = Combo1.Text
m1 = fx.ComOpen(COM1) '打开串口
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOnStatus, M, 2) '使PLC中的元件M2 ON,X正转
If back Then
Text2.Text = "M2 on"
End If
End Sub
Private Sub Command3_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOffStatus, M, 2) '使PLC中的元件M2 OFF,X停止
If back Then
Text2.Text = "M2 off"
End If
End Sub
Private Sub Command4_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOnStatus, M, 3)
If back Then
Text2.Text = "M3 on"
End If
End Sub
Private Sub Command4_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOffStatus, M, 3)
If back Then
Text2.Text = "M3 off"
End If
End Sub
Private Sub Command5_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOnStatus, M, 4)
If back Then
Text2.Text = "M4 on"
End If
End Sub
Private Sub Command5_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOffStatus, M, 4)
If back Then
Text2.Text = "M4 off"
End If
End Sub
Private Sub Command6_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOnStatus, M, 5)
If back Then
Text2.Text = "M5 on"
End If
End Sub
Private Sub Command6_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
back = fx.Device_SingleForce(fxOffStatus, M, 5)
If back Then
Text2.Text = "M5 off"
End If
End Sub
Private Sub Command7_Click()
fadat.PLCdata(0) = Val(Text4.Text) '写入X 速度
fadat.PLCdata(1) = 0
fadat.PLCdata(2) = Val(Text5.Text) '写入Y速度
back = fx.Group_Access(fxWriteStatus, D, 132, 4, fadat) '把X速度写到D132,Y速度写到D134
If back Then
Text2.Text = "速度写入成功"
Else
Text2.Text = "速度写入失败"
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
m1 = fx.ComOpen(COM1)
End Sub
Private Sub Form_Unload(Cancel As Integer)
m1 = fx.ComClose
End Sub
Private Sub Timer1_Timer()
postion = fx.Group_Access(fxReadStatus, D, 10, 4, fadat) '读取X位置D10,Y位置D12
If postion Then
Text1.Text = fadat.PLCdata(0)
Text3.Text = fadat.PLCdata(2)
End If
postion1 = fx.Group_Access(fxReadStatus, D, 132, 4, fadat) ''读取X速度D132,Y速度D134
If postion1 Then
Text6.Text = fadat.PLCdata(0)
Text7.Text = fadat.PLCdata(2)
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -