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

📄 仪器通信测试系统.frm

📁 一个小巧的通信检测软件
💻 FRM
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "通信测试系统"
   ClientHeight    =   3180
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7980
   Icon            =   "仪器通信测试系统.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3180
   ScaleWidth      =   7980
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   2880
      TabIndex        =   17
      Top             =   3600
      Width           =   975
   End
   Begin VB.TextBox Text2 
      Height          =   615
      Left            =   240
      TabIndex        =   16
      Text            =   "Text2"
      Top             =   3480
      Width           =   2055
   End
   Begin VB.CommandButton CommandEnd 
      Caption         =   "结 束"
      Height          =   495
      Left            =   2520
      TabIndex        =   15
      Top             =   1920
      Width           =   855
   End
   Begin VB.TextBox Text1 
      Height          =   495
      Left            =   4920
      TabIndex        =   14
      Text            =   "Text1"
      Top             =   3600
      Width           =   2775
   End
   Begin MSComctlLib.ProgressBar ProgressBar1 
      Height          =   375
      Left            =   3900
      TabIndex        =   8
      Top             =   1320
      Width           =   3615
      _ExtentX        =   6376
      _ExtentY        =   661
      _Version        =   393216
      Appearance      =   0
   End
   Begin VB.CommandButton CommandSave 
      Caption         =   "保存数据"
      Height          =   495
      Left            =   4200
      TabIndex        =   7
      Top             =   1920
      Width           =   1455
   End
   Begin VB.CommandButton CommandInput 
      Caption         =   "数据导入"
      Enabled         =   0   'False
      Height          =   495
      Left            =   6480
      TabIndex        =   6
      Top             =   600
      Width           =   1095
   End
   Begin VB.CommandButton CommandClear 
      Caption         =   "清仪器数据"
      Enabled         =   0   'False
      Height          =   495
      Left            =   5880
      TabIndex        =   5
      Top             =   1920
      Width           =   1455
   End
   Begin VB.CommandButton CommandStrat 
      Caption         =   "开 始"
      Height          =   495
      Left            =   240
      TabIndex        =   1
      Top             =   1920
      Width           =   855
   End
   Begin VB.CommandButton CommandTest 
      Caption         =   "通信测试"
      Enabled         =   0   'False
      Height          =   495
      Left            =   1200
      TabIndex        =   0
      Top             =   1920
      Width           =   1215
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   -120
      Top             =   -120
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      BaudRate        =   2400
   End
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0FFC0&
      ForeColor       =   &H80000008&
      Height          =   495
      Left            =   3840
      ScaleHeight     =   465
      ScaleWidth      =   3705
      TabIndex        =   12
      Top             =   1260
      Width           =   3735
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Caption         =   "--- 设计开发:尹洪峰  Copyright @ 2005, All Rights Reserved ---"
      ForeColor       =   &H000000FF&
      Height          =   255
      Left            =   0
      TabIndex        =   18
      Top             =   2880
      Width           =   8055
   End
   Begin VB.Label LabelTest 
      Alignment       =   2  'Center
      BackColor       =   &H00FFC0FF&
      BeginProperty Font 
         Name            =   "幼圆"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   540
      TabIndex        =   13
      Top             =   900
      Width           =   2535
   End
   Begin VB.Line Line9 
      X1              =   7440
      X2              =   7680
      Y1              =   240
      Y2              =   240
   End
   Begin VB.Label Label5 
      Alignment       =   2  'Center
      Caption         =   "条记录"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   5280
      TabIndex        =   11
      Top             =   720
      Width           =   735
   End
   Begin VB.Label LabelNum 
      Alignment       =   2  'Center
      Caption         =   "?"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4800
      TabIndex        =   10
      Top             =   720
      Width           =   495
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "一共有"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   4080
      TabIndex        =   9
      Top             =   720
      Width           =   735
   End
   Begin VB.Label LabelInfo 
      Alignment       =   2  'Center
      BackColor       =   &H00C0FFC0&
      Height          =   255
      Left            =   4140
      TabIndex        =   4
      Top             =   120
      Width           =   3135
   End
   Begin VB.Line Line8 
      X1              =   3720
      X2              =   3720
      Y1              =   240
      Y2              =   2640
   End
   Begin VB.Line Line7 
      X1              =   7680
      X2              =   7680
      Y1              =   240
      Y2              =   2640
   End
   Begin VB.Line Line6 
      X1              =   3720
      X2              =   3960
      Y1              =   240
      Y2              =   240
   End
   Begin VB.Line Line5 
      X1              =   7680
      X2              =   3720
      Y1              =   2640
      Y2              =   2640
   End
   Begin VB.Line Line4 
      X1              =   120
      X2              =   120
      Y1              =   240
      Y2              =   2640
   End
   Begin VB.Line Line3 
      X1              =   3480
      X2              =   3480
      Y1              =   240
      Y2              =   2640
   End
   Begin VB.Line Line2 
      X1              =   120
      X2              =   3480
      Y1              =   240
      Y2              =   240
   End
   Begin VB.Line Line1 
      X1              =   3480
      X2              =   120
      Y1              =   2640
      Y2              =   2640
   End
   Begin VB.Label LabelTback 
      Alignment       =   2  'Center
      BackColor       =   &H00FFC0FF&
      BeginProperty Font 
         Name            =   "幼圆"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   480
      TabIndex        =   3
      Top             =   600
      Width           =   2655
   End
   Begin VB.Label Label1 
      BackColor       =   &H00800080&
      Height          =   1095
      Left            =   360
      TabIndex        =   2
      Top             =   480
      Width           =   2895
   End
   Begin VB.Image Image1 
      Height          =   480
      Left            =   3915
      Picture         =   "仪器通信测试系统.frx":08CA
      Top             =   0
      Width           =   3585
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
Text2.Text = Len("051103/100004/99.99/01/N/01/1*")
End Sub

Private Sub CommandEnd_Click()
    MSComm1.PortOpen = False
    MSComm1.InBufferCount = 0    '清空接收区
    CommandTest.Enabled = False
End Sub

Private Sub CommandInput_Click()
On Error Resume Next
MSComm1.Output = "SALLE"
ProgressBar1.Visible = True
ProgressBar1.Min = 1
ProgressBar1.Max = 100
ProgressBar1.Value = 1 '初始化
For c = 1 To 100
ProgressBar1.Value = c '跟踪进度
Sleep (25)
Next c
ProgressBar1.Value = 1
'ProgressBar1.Visible = False '任务结束
rvcdata = MSComm1.Input
Text1.Text = rvcdata
If rvcdata = "FNO-DATA" Then
    LabelInfo.Caption = "仪器内没有数据"
    LabelNum.Caption = 0
  Else
    x = Len(rvcdata) - 2
    y = x / 30
    LabelNum = y
    LabelInfo.Caption = "数据导入成功"
End If
End Sub

Private Sub MSComm1_OnComm()

Dim rvcdata As String             '定义接收数据
Select Case MSComm1.CommEvent
Case comEvRecieve                 '有接收事件发生
rvcdata = MSComm1.Input               '接收数据
Text1.Text = rvcdata              '显示接收数据

End Select
End Sub '
Private Sub CommandClear_Click()
MSComm1.Output = "SCLRE"
rcvdata = MSComm1.Input
LabelInfo.Caption = "数据已清空"
MSComm1.InBufferCount = 0    '清空接收区
End Sub

Private Sub Form_Load()
    Dim rcvdata As String
    Dim js As Integer
    Dim x As String
    Dim y As String
    LabelInfo.BackStyle = 0
'    LabelInfo.Caption = App.Path
End Sub

Private Sub CommandStrat_Click()
    On Error Resume Next
        CommandTest.Enabled = True
        CommandInput.Enabled = True
        CommandClear.Enabled = True
        MSComm1.PortOpen = True
        MSComm1.Settings = "2400,N,8,1" '设置初始化参数
        LabelTest.Caption = "准备就绪"
                  
End Sub

Private Sub CommandTest_Click()
    On Error Resume Next
    MSComm1.Output = "R"
    Sleep (800)
    rcvdata = MSComm1.Input
    Text1.Text = rcvdata
    If Mid(rcvdata, 1, 2) = "OK" Then
          
          LabelTest.Caption = "通信成功"
       Else
          
          LabelTest.Caption = "很遗憾,通信未能建立!!!"
     End If

End Sub
'Private Sub Form_Load()
'MSComm1.CommPort = 2 '使用COM2口
'MSComm1.Settings = "9600,N,8,1" '设置初始化参数
'MSComm1.PortOpen = True '打开串口
'End Sub


'Private Sub Command3_Click()
'Dim Sends As String
'Sends = InputBox("请输入数据", "输入数据")
'Text1 = Sends
'End Sub

'Private Sub Command1_Click()
'MSComm1.RTSEnable = False
'Dim Sends As String                        '定义发送数据
'Sends = Text1.Text                        '变量赋值
'MSComm1.OutBufferCount = 0
'MSComm1.Output = Sends              '发送数据
'End Sub
'
'Private Sub Command2_Click()
'MSComm1.PortOpen = False                '关闭串口
'Unload Form1 '卸载窗体
'End If
'End Sub
'
'
'Private Sub Command4_Click()              ‘发送按钮
'MSComm1.RTSEnable = Ture
'End Sub


'Private Sub MSComm1_OnComm()
'Dim Rec As String                   '定义接收数据
'Select Case MSComm1.CommEvent
'Case comEvRecieve                 '有接收事件发生
'Rec = MSComm1.Input            '接收数据
'Text2.Text = Rec              '显示接收数据
'MSComm1.InBufferCount = 0    '清空接收区
'End Select
'End Sub'
'


⌨️ 快捷键说明

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