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

📄 form22345.frm

📁 光洋PLC串口通讯HEX编程实例,工控上用的,有用的朋友不要留情!!下吧!
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form2 
   Caption         =   "CCM2协议通讯"
   ClientHeight    =   5610
   ClientLeft      =   3585
   ClientTop       =   2550
   ClientWidth     =   7380
   LinkTopic       =   "Form2"
   ScaleHeight     =   5610
   ScaleWidth      =   7380
   Begin VB.Timer Timer1 
      Interval        =   200
      Left            =   105
      Top             =   3120
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   45
      Top             =   3690
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      ParitySetting   =   1
   End
   Begin VB.Frame Frame2 
      Caption         =   "读取数据"
      Height          =   2610
      Left            =   4440
      TabIndex        =   6
      Top             =   285
      Width           =   2370
      Begin VB.CommandButton Command3 
         Caption         =   "读出"
         Height          =   735
         Left            =   600
         TabIndex        =   9
         Top             =   1800
         Width           =   975
      End
      Begin VB.TextBox Text6 
         Height          =   285
         Left            =   1200
         TabIndex        =   8
         Text            =   "2000"
         Top             =   1320
         Width           =   855
      End
      Begin VB.TextBox Text5 
         Height          =   285
         Left            =   360
         TabIndex        =   7
         Top             =   720
         Width           =   1455
      End
      Begin VB.Label Label10 
         Caption         =   "寄存器号:R"
         Height          =   255
         Left            =   120
         TabIndex        =   11
         Top             =   1365
         Width           =   1095
      End
      Begin VB.Label Label9 
         Caption         =   "寄存器数据显示:"
         Height          =   255
         Left            =   360
         TabIndex        =   10
         Top             =   360
         Width           =   1575
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "数据输入"
      Height          =   2580
      Left            =   360
      TabIndex        =   0
      Top             =   315
      Width           =   3480
      Begin VB.CommandButton Command4 
         Caption         =   "取消输入"
         Height          =   420
         Left            =   1020
         TabIndex        =   18
         Top             =   2010
         Width           =   915
      End
      Begin VB.ComboBox Combo1 
         Height          =   315
         Left            =   1920
         TabIndex        =   15
         Top             =   360
         Width           =   495
      End
      Begin VB.TextBox Text2 
         Height          =   285
         Left            =   1440
         TabIndex        =   3
         Text            =   "2000"
         Top             =   720
         Width           =   975
      End
      Begin VB.CommandButton Command1 
         Caption         =   "发送数据"
         Height          =   1215
         Left            =   2640
         TabIndex        =   2
         Top             =   720
         Width           =   615
      End
      Begin VB.TextBox Text1 
         Height          =   285
         Left            =   480
         TabIndex        =   1
         Text            =   "00"
         Top             =   1680
         Width           =   1935
      End
      Begin VB.Label Label4 
         Caption         =   "端口号:"
         Height          =   255
         Left            =   840
         TabIndex        =   17
         Top             =   405
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "COM"
         Height          =   255
         Left            =   1560
         TabIndex        =   16
         Top             =   405
         Width           =   375
      End
      Begin VB.Label Label2 
         Caption         =   "寄存器号:R"
         Height          =   255
         Left            =   360
         TabIndex        =   5
         Top             =   765
         Width           =   1095
      End
      Begin VB.Label Label1 
         Caption         =   "写入数据:"
         Height          =   255
         Index           =   0
         Left            =   360
         TabIndex        =   4
         Top             =   1320
         Width           =   1575
      End
   End
   Begin VB.Label Label14 
      Caption         =   "  Q0        Q1         Q2        Q3         Q4         Q5        Q6         Q7"
      Height          =   255
      Left            =   1305
      TabIndex        =   14
      Top             =   4305
      Width           =   4695
   End
   Begin VB.Label Label13 
      Caption         =   "本例的通讯设置为:9600bps,奇校验,8位数据位,1位停止位,HEX方式,PLC局号为1"
      Height          =   255
      Left            =   255
      TabIndex        =   13
      Top             =   5160
      Width           =   6930
   End
   Begin VB.Label Label12 
      Caption         =   "PLC输出点状态显示"
      Height          =   255
      Left            =   2865
      TabIndex        =   12
      Top             =   3345
      Width           =   1815
   End
   Begin VB.Image imgr1 
      Height          =   555
      Left            =   1785
      Picture         =   "Form22345.frx":0000
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr2 
      Height          =   555
      Left            =   2385
      Picture         =   "Form22345.frx":1072
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr3 
      Height          =   555
      Left            =   2985
      Picture         =   "Form22345.frx":20E4
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr4 
      Height          =   555
      Left            =   3585
      Picture         =   "Form22345.frx":3156
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr5 
      Height          =   555
      Left            =   4185
      Picture         =   "Form22345.frx":41C8
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr6 
      Height          =   555
      Left            =   4785
      Picture         =   "Form22345.frx":523A
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr7 
      Height          =   555
      Left            =   5385
      Picture         =   "Form22345.frx":62AC
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgr0 
      Height          =   555
      Left            =   1185
      Picture         =   "Form22345.frx":731E
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   7
      Left            =   5385
      Picture         =   "Form22345.frx":8390
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   6
      Left            =   4785
      Picture         =   "Form22345.frx":A9CC
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   5
      Left            =   4185
      Picture         =   "Form22345.frx":D008
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   4
      Left            =   3585
      Picture         =   "Form22345.frx":F644
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   3
      Left            =   2985
      Picture         =   "Form22345.frx":11C80
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   2
      Left            =   2385
      Picture         =   "Form22345.frx":142BC
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   1
      Left            =   1785
      Picture         =   "Form22345.frx":168F8
      Top             =   3705
      Width           =   555
   End
   Begin VB.Image imgg0 
      Height          =   555
      Index           =   0
      Left            =   1185
      Picture         =   "Form22345.frx":18F34
      Top             =   3705
      Width           =   555
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Dim sbuf$, sbuf1$, rbuf$, rbuf1$, i!, lg!
Dim ret!
Dim setstring As String
Dim comset As String
Dim comm_fg As Boolean
Dim send_fg As Boolean
Dim stop_fg As Boolean
Dim realcom_fg As Boolean
Dim data() As Byte

Private Sub Combo1_Change()
    If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
    setstring = "9600,o,8,1"
    comset = Combo1.Text
    MSComm1.CommPort = comset  '设置通讯口

⌨️ 快捷键说明

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