⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 VB与FX系列PLC通讯的代码,简单易读.
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Top             =   4440
      Width           =   540
   End
   Begin VB.Label Label36 
      AutoSize        =   -1  'True
      Caption         =   "字号码:"
      Height          =   180
      Left            =   2760
      TabIndex        =   66
      Top             =   4440
      Width           =   720
   End
   Begin VB.Label Label35 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   65
      Top             =   4440
      Width           =   1080
   End
   Begin VB.Label Label34 
      AutoSize        =   -1  'True
      Caption         =   "写(D)"
      Height          =   180
      Left            =   360
      TabIndex        =   64
      Top             =   4680
      Width           =   630
   End
   Begin VB.Label Label33 
      AutoSize        =   -1  'True
      Caption         =   "DR_Write:"
      Height          =   180
      Left            =   360
      TabIndex        =   63
      Top             =   4440
      Width           =   810
   End
   Begin VB.Label Label32 
      AutoSize        =   -1  'True
      Caption         =   "DR_Read :"
      Height          =   180
      Left            =   360
      TabIndex        =   57
      Top             =   3720
      Width           =   810
   End
   Begin VB.Label Label31 
      AutoSize        =   -1  'True
      Caption         =   "读(D)"
      Height          =   180
      Left            =   360
      TabIndex        =   56
      Top             =   3960
      Width           =   630
   End
   Begin VB.Label Label30 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   55
      Top             =   3720
      Width           =   1080
   End
   Begin VB.Label Label29 
      AutoSize        =   -1  'True
      Caption         =   "字号码:"
      Height          =   180
      Left            =   2760
      TabIndex        =   54
      Top             =   3720
      Width           =   720
   End
   Begin VB.Label Label28 
      AutoSize        =   -1  'True
      Caption         =   "状态值"
      Height          =   195
      Left            =   4080
      TabIndex        =   53
      Top             =   3720
      Width           =   540
   End
   Begin VB.Label Label27 
      AutoSize        =   -1  'True
      Caption         =   "MR_Write:"
      Height          =   195
      Left            =   360
      TabIndex        =   48
      Top             =   3000
      Width           =   765
   End
   Begin VB.Label Label26 
      AutoSize        =   -1  'True
      Caption         =   "写(M)"
      Height          =   195
      Left            =   360
      TabIndex        =   47
      Top             =   3240
      Width           =   675
   End
   Begin VB.Label Label25 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   46
      Top             =   3000
      Width           =   1080
   End
   Begin VB.Label Label24 
      AutoSize        =   -1  'True
      Caption         =   "字节号码:"
      Height          =   195
      Left            =   2760
      TabIndex        =   45
      Top             =   3000
      Width           =   900
   End
   Begin VB.Label Label23 
      AutoSize        =   -1  'True
      Caption         =   "写入值"
      Height          =   195
      Left            =   4080
      TabIndex        =   44
      Top             =   3000
      Width           =   540
   End
   Begin VB.Label Label22 
      AutoSize        =   -1  'True
      Caption         =   "状态值"
      Height          =   195
      Left            =   5400
      TabIndex        =   43
      Top             =   3000
      Width           =   540
   End
   Begin VB.Label Label21 
      AutoSize        =   -1  'True
      Caption         =   "状态值"
      Height          =   195
      Left            =   4080
      TabIndex        =   37
      Top             =   2280
      Width           =   540
   End
   Begin VB.Label Label20 
      AutoSize        =   -1  'True
      Caption         =   "字节号码:"
      Height          =   195
      Left            =   2760
      TabIndex        =   36
      Top             =   2280
      Width           =   900
   End
   Begin VB.Label Label19 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   35
      Top             =   2280
      Width           =   1080
   End
   Begin VB.Label Label18 
      AutoSize        =   -1  'True
      Caption         =   "读(M)"
      Height          =   195
      Left            =   360
      TabIndex        =   34
      Top             =   2520
      Width           =   675
   End
   Begin VB.Label Label17 
      AutoSize        =   -1  'True
      Caption         =   "MR_Read :"
      Height          =   195
      Left            =   360
      TabIndex        =   33
      Top             =   2280
      Width           =   825
   End
   Begin VB.Label Label16 
      AutoSize        =   -1  'True
      Caption         =   "状态值"
      Height          =   195
      Left            =   5400
      TabIndex        =   28
      Top             =   1560
      Width           =   540
   End
   Begin VB.Label Label15 
      AutoSize        =   -1  'True
      Caption         =   "写入值"
      Height          =   195
      Left            =   4080
      TabIndex        =   26
      Top             =   1560
      Width           =   540
   End
   Begin VB.Label Label14 
      AutoSize        =   -1  'True
      Caption         =   "字节号码:"
      Height          =   195
      Left            =   2760
      TabIndex        =   25
      Top             =   1560
      Width           =   900
   End
   Begin VB.Label Label13 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   24
      Top             =   1560
      Width           =   1080
   End
   Begin VB.Label Label12 
      AutoSize        =   -1  'True
      Caption         =   "写输出(Y)"
      Height          =   195
      Left            =   240
      TabIndex        =   23
      Top             =   1800
      Width           =   1005
   End
   Begin VB.Label Label11 
      AutoSize        =   -1  'True
      Caption         =   "DO_Write:"
      Height          =   195
      Left            =   360
      TabIndex        =   22
      Top             =   1560
      Width           =   750
   End
   Begin VB.Label Label10 
      AutoSize        =   -1  'True
      Caption         =   "DO_Read :"
      Height          =   195
      Left            =   360
      TabIndex        =   17
      Top             =   840
      Width           =   810
   End
   Begin VB.Label Label9 
      AutoSize        =   -1  'True
      Caption         =   "读输出(Y)"
      Height          =   195
      Left            =   240
      TabIndex        =   16
      Top             =   1080
      Width           =   1005
   End
   Begin VB.Label Label8 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   15
      Top             =   840
      Width           =   1080
   End
   Begin VB.Label Label7 
      AutoSize        =   -1  'True
      Caption         =   "字节号码:"
      Height          =   195
      Left            =   2760
      TabIndex        =   14
      Top             =   840
      Width           =   900
   End
   Begin VB.Label Label6 
      AutoSize        =   -1  'True
      Caption         =   "状态值"
      Height          =   195
      Left            =   4080
      TabIndex        =   13
      Top             =   840
      Width           =   540
   End
   Begin VB.Label Label5 
      AutoSize        =   -1  'True
      Caption         =   "状态值"
      Height          =   195
      Left            =   4080
      TabIndex        =   7
      Top             =   120
      Width           =   540
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      Caption         =   "字节号码:"
      Height          =   195
      Left            =   2760
      TabIndex        =   5
      Top             =   120
      Width           =   900
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      Caption         =   "通讯端口号码"
      Height          =   195
      Left            =   1440
      TabIndex        =   3
      Top             =   120
      Width           =   1080
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "读输入(X)"
      Height          =   195
      Left            =   240
      TabIndex        =   2
      Top             =   360
      Width           =   1005
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "DI_Read :"
      Height          =   195
      Left            =   360
      TabIndex        =   1
      Top             =   120
      Width           =   735
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Me.Top = Screen.Height / 2 - Me.Height / 2
Me.Left = Screen.Width / 2 - Me.Width / 2
End Sub

Private Sub Command1_Click()
Dim Obj As New FXPLC
Dim a, b As Integer
Dim ReadData As Integer
If Text1.Text = "" Or Text2.Text = "" Then
   MsgBox "参数未填完整!", , "DI_Read"
   Exit Sub
End If
Start_Run
a = Val(Text1.Text)
b = Val(Text2.Text)
 ReadData = Obj.DI_Read(a, b)
 Text3.Text = CStr(ReadData)
 Stop_Run
End Sub

Private Sub Command2_Click()
'Dim Obj As New FXPLC
'Dim a, b As Integer
'Dim ReadData As Integer
'If Text6.Text = "" Or Text5.Text = "" Then
   'MsgBox "参数未填完整!", , "DO_Read"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text6.Text)
'b = Val(Text5.Text)
 'ReadData = Obj.DO_Read(a, b)
 'Text4.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command3_Click()
'Dim Obj As New FXPLC
'Dim a, b, c As Integer
'Dim ReadData As Integer
'If Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Then
   'MsgBox "参数未填完整!", , "DO_Write"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text7.Text)
'b = Val(Text8.Text)
'c = Val(Text9.Text)
 'ReadData = Obj.DO_Write(a, b, c)
 'Text10.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command4_Click()
'Dim Obj As New FXPLC
'Dim a, b As Integer
'Dim ReadData As Integer
'If Text11.Text = "" Or Text12.Text = "" Then
  ' MsgBox "参数未填完整!", , "MR_Read"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text11.Text)
'b = Val(Text12.Text)
 'ReadData = Obj.MR_Read(a, b)
 'Text13.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command5_Click()
'Dim Obj As New FXPLC
'Dim a, b, c As Integer
'Dim ReadData As Integer
'If Text15.Text = "" Or Text16.Text = "" Or Text17.Text = "" Then
   'MsgBox "参数未填完整!", , "MR_Write"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text17.Text)
'b = Val(Text16.Text)
'c = Val(Text15.Text)
 'ReadData = Obj.MR_Write(a, b, c)
 'Text14.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command6_Click()
'Dim Obj As New FXPLC
'Dim a, b As Integer
'Dim ReadData As Integer
'If Text20.Text = "" Or Text19.Text = "" Then
   'MsgBox "参数未填完整!", , "DR_Read"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text20.Text)
'b = Val(Text19.Text)
 'ReadData = Obj.DR_Read(a, b)
 'Text18.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command7_Click()
'Dim Obj As New FXPLC
'Dim a, b, c As Integer
'Dim ReadData As Integer
'If Text21.Text = "" Or Text22.Text = "" Or Text23.Text = "" Then
  ' MsgBox "参数未填完整!", , "DR_Write"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text21.Text)
'b = Val(Text22.Text)
'c = Val(Text23.Text)
 'ReadData = Obj.DR_Write(a, b, c)
 'Text24.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command8_Click()
'Dim Obj As New FXPLC
'Dim a, c As Integer
'Dim b As String
'Dim ReadData As Integer
'If Text27.Text = "" Or Text26.Text = "" Or Text25.Text = "" Then
  ' MsgBox "参数未填完整!", , "BT_Force"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text27.Text)
'b = Text26.Text
'c = Val(Text25.Text)
 'ReadData = Obj.BT_Force(a, b, c)
 'Text28.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub

Private Sub Command9_Click()
'Dim Obj As New FXPLC
'Dim a, c As Integer
'Dim b As String
'Dim ReadData As Integer
'If Text31.Text = "" Or Text30.Text = "" Or Text29.Text = "" Then
   'MsgBox "参数未填完整!", , "BT_Clear"
   'Exit Sub
'End If
'Start_Run
'a = Val(Text31.Text)
'b = Text30.Text
'c = Val(Text29.Text)
 'ReadData = Obj.BT_Clear(a, b, c)
 'Text32.Text = CStr(ReadData)
 'Stop_Run
 MsgBox "正式版才有此函数!"
End Sub



Sub Start_Run()
 Command1.Enabled = False
 Command2.Enabled = False
 Command3.Enabled = False
 Command4.Enabled = False
 Command5.Enabled = False
 Command6.Enabled = False
 Command7.Enabled = False
 Command8.Enabled = False
 Command9.Enabled = False
End Sub
Sub Stop_Run()
 Command1.Enabled = True
 Command2.Enabled = True
 Command3.Enabled = True
 Command4.Enabled = True
 Command5.Enabled = True
 Command6.Enabled = True
 Command7.Enabled = True
 Command8.Enabled = True
 Command9.Enabled = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Command10_Click()
Unload Me
End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -