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

📄 vbterm.frm

📁 VB做的测绘仪器通讯程序! 设置通讯参数一定要和仪器里的一致!
💻 FRM
📖 第 1 页 / 共 2 页
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
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 frmTerminal 
   ClientHeight    =   4440
   ClientLeft      =   2940
   ClientTop       =   2055
   ClientWidth     =   6105
   ForeColor       =   &H00000000&
   Icon            =   "vbterm.frx":0000
   LinkMode        =   1  'Source
   LinkTopic       =   "Form1"
   ScaleHeight     =   4440
   ScaleWidth      =   6105
   StartUpPosition =   2  '屏幕中心
   WindowState     =   2  'Maximized
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   240
      Top             =   2760
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   16
      ImageHeight     =   16
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   6
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "vbterm.frx":27A2
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "vbterm.frx":28B6
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "vbterm.frx":29CA
            Key             =   ""
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "vbterm.frx":2ADE
            Key             =   ""
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "vbterm.frx":2F32
            Key             =   ""
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "vbterm.frx":3386
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin MSComctlLib.StatusBar sbrStatus 
      Align           =   2  'Align Bottom
      Height          =   255
      Left            =   0
      TabIndex        =   1
      Top             =   4185
      Width           =   6105
      _ExtentX        =   10769
      _ExtentY        =   450
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   3
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Text            =   "状态:"
            TextSave        =   "状态:"
            Key             =   "Status"
            Object.ToolTipText     =   "状态:"
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            AutoSize        =   1
            Object.Width           =   5106
            Key             =   "Settings"
            Object.ToolTipText     =   "端口设置"
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Key             =   "ConnectTime"
            Object.ToolTipText     =   "通讯时间"
         EndProperty
      EndProperty
   End
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   3495
      Left            =   1680
      TabIndex        =   0
      Top             =   600
      Width           =   4215
      _ExtentX        =   7435
      _ExtentY        =   6165
      _Version        =   393217
      BackColor       =   16777215
      ScrollBars      =   3
      DisableNoScroll =   -1  'True
      TextRTF         =   $"vbterm.frx":5B3A
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Timer Timer2 
      Enabled         =   0   'False
      Interval        =   2000
      Left            =   210
      Top             =   3645
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   165
      Top             =   1815
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   45
      Top             =   510
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      InBufferSize    =   31000
      RThreshold      =   1
      RTSEnable       =   -1  'True
      SThreshold      =   1
      EOFEnable       =   -1  'True
      InputMode       =   1
   End
   Begin MSComDlg.CommonDialog OpenLog 
      Left            =   105
      Top             =   1170
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      DefaultExt      =   "LOG"
      FileName        =   "Open Communications Log File"
      Filter          =   "Log File (*.log)|*.log;"
      FilterIndex     =   501
      FontSize        =   0
      MaxFileSize     =   9000
   End
   Begin MSComctlLib.Toolbar tbrToolBar 
      Height          =   390
      Left            =   0
      Negotiate       =   -1  'True
      TabIndex        =   2
      Top             =   0
      Width           =   5205
      _ExtentX        =   9181
      _ExtentY        =   688
      ButtonWidth     =   609
      ButtonHeight    =   582
      ImageList       =   "ImageList1"
      DisabledImageList=   "ImageList1"
      HotImageList    =   "ImageList1"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   12
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "tool打开"
            Object.ToolTipText     =   "打开定位文件"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "tool关闭"
            Object.ToolTipText     =   "关闭定位文件"
            ImageIndex      =   4
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "tool端口设置"
            Object.ToolTipText     =   "端口设置"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "tool数据"
            Object.ToolTipText     =   "数据传输"
            ImageIndex      =   5
         EndProperty
         BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "tool保存"
            Object.ToolTipText     =   "保存文件"
            ImageIndex      =   2
         EndProperty
         BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Style           =   3
         EndProperty
         BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Key             =   "tool关于"
            Object.ToolTipText     =   "关于....."
            ImageIndex      =   6
         EndProperty
      EndProperty
      Begin VB.Image Image1 
         BorderStyle     =   1  'Fixed Single
         Height          =   255
         Left            =   7440
         Stretch         =   -1  'True
         Top             =   2000
         Width           =   735
      End
   End
   Begin VB.Image imgNotConnected 
      Height          =   240
      Left            =   5760
      Picture         =   "vbterm.frx":5D74
      Stretch         =   -1  'True
      ToolTipText     =   "端口关"
      Top             =   0
      Width           =   240
   End
   Begin VB.Image imgConnected 
      Height          =   240
      Left            =   5760
      Picture         =   "vbterm.frx":5EBE
      Stretch         =   -1  'True
      ToolTipText     =   "端口开"
      Top             =   0
      Width           =   240
   End
   Begin VB.Menu mnuFile 
      Caption         =   "文件(&F)"
      Begin VB.Menu mnuOpenLog 
         Caption         =   "打开定位文件(&O)"
      End
      Begin VB.Menu mnuCloseLog 
         Caption         =   "关闭定位文件(&C)"
         Enabled         =   0   'False
      End
      Begin VB.Menu M3 
         Caption         =   "-"
      End
      Begin VB.Menu mnuFileExit 
         Caption         =   "退出(&E)"
         Shortcut        =   ^Q
      End
   End
   Begin VB.Menu mnuPort 
      Caption         =   "端口(&C)"
      Begin VB.Menu mnuOpen 
         Caption         =   "打开端口(&O)"
      End
      Begin VB.Menu MBar1 
         Caption         =   "-"
      End
      Begin VB.Menu mnuProperties 
         Caption         =   "端口设置(&S)"
      End
   End
   Begin VB.Menu mnuMSComm 
      Caption         =   "数据接收(&M)"
      Begin VB.Menu mnuInputLen 
         Caption         =   "接收数据(&I)"
      End
      Begin VB.Menu Bar3 
         Caption         =   "-"
      End
      Begin VB.Menu MUNSAVE 
         Caption         =   "保存    (&S)"
      End
      Begin VB.Menu KKKK 
         Caption         =   "-"
      End
      Begin VB.Menu MUNKILL 
         Caption         =   "清除    (&K)"
      End
   End
   Begin VB.Menu MUN帮助 
      Caption         =   "帮助(&H)"
      Begin VB.Menu mun主题 
         Caption         =   "主题(&C)"
         Shortcut        =   {F1}
      End
      Begin VB.Menu mun索引 
         Caption         =   "索引(&I)..."
      End
      Begin VB.Menu mx 
         Caption         =   "-"
      End
      Begin VB.Menu MUN关于 
         Caption         =   "关于(&A)..."
      End
   End
End
Attribute VB_Name = "frmTerminal"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
                        
Dim Ret As Integer      ' Scratch integer.
Dim Temp As String      ' Scratch string.
Dim hLogFile As Integer ' Handle of open log file.
Dim StartTime As Date   ' Stores starting time for port timer

Private Sub Form_Load()
    Dim CommPort As String, Handshaking As String, Settings As String
    On Error Resume Next
    
    ' Set the default color for the terminal
    RichTextBox1.SelLength = Len(RichTextBox1)
    RichTextBox1.SelText = ""
   ' RichTextBox1.ForeColor = vbBlue
       
    ' Set Title
    App.Title = "仪器通讯程序"
    
    ' Set up status indicator light
    imgNotConnected.ZOrder
       
    ' Center Form
    frmTerminal.Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
    
    ' Load Registry Settings
    
    Settings = GetSetting(App.Title, "端口设置", "传输属性", "") ' frmTerminal.MSComm1.Settings]\
    If Settings <> "" Then
        MSComm1.Settings = Settings
        If Err Then
            MsgBox Error$, 48
            Exit Sub
        End If
    End If
    
    CommPort = GetSetting(App.Title, "端口设置", "通讯端口号", "") ' frmTerminal.MSComm1.CommPort
    If CommPort <> "" Then MSComm1.CommPort = CommPort
    
    Handshaking = GetSetting(App.Title, "端口设置", "传输协议", "") 'frmTerminal.MSComm1.Handshaking
    If Handshaking <> "" Then
        MSComm1.Handshaking = Handshaking
        If Err Then
            MsgBox Error$, 48
            Exit Sub
        End If
    End If
    
    Echo = GetSetting(App.Title, "端口设置", "响应", "") ' Echo
    On Error GoTo 0

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        Close
End Sub

Private Sub Form_Resize()
   On Error Resume Next
   ' Resize the Term (display) control
   RichTextBox1.Move 0, tbrToolBar.Height, frmTerminal.ScaleWidth, frmTerminal.ScaleHeight - sbrStatus.Height - tbrToolBar.Height
   
   'Position the status indicator light
   'Frame1.Left = ScaleWidth - Frame1.Width * 1.5
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Dim Counter As Long

    If MSComm1.PortOpen Then
       ' Wait 10 seconds for data to be transmitted.
       Counter = Timer + 10
       Do While MSComm1.OutBufferCount
          Ret = DoEvents()
          If Timer > Counter Then
             Select Case MsgBox("Data cannot be sent", 34)
                ' Cancel.
                Case 3

⌨️ 快捷键说明

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