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

📄 frmprotocols.frm

📁 这是一本学习串口编程喝计算机监控的好书里面是用VB开发的源代码
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmProtocols 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Protocols of Data Packages"
   ClientHeight    =   3840
   ClientLeft      =   1635
   ClientTop       =   1530
   ClientWidth     =   6120
   Icon            =   "frmProtocols.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3840
   ScaleMode       =   0  'User
   ScaleWidth      =   6120
   Begin VB.CommandButton cmdClose 
      Caption         =   "Close"
      Height          =   330
      Left            =   5040
      TabIndex        =   6
      Tag             =   "&Close"
      Top             =   0
      Width           =   960
   End
   Begin VB.CommandButton cmdCheckProtocol 
      Caption         =   "Check &Protocol"
      Height          =   330
      Left            =   3240
      TabIndex        =   5
      Tag             =   "&Close"
      Top             =   0
      Width           =   1320
   End
   Begin VB.PictureBox picButtons 
      Align           =   1  'Align Top
      Appearance      =   0  'Flat
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   330
      Left            =   0
      ScaleHeight     =   330
      ScaleWidth      =   6120
      TabIndex        =   2
      TabStop         =   0   'False
      Top             =   0
      Width           =   6120
      Begin VB.CommandButton cmdAddNew 
         Caption         =   "&Add New"
         Height          =   330
         Left            =   2040
         TabIndex        =   4
         Tag             =   "&Sort"
         Top             =   0
         Width           =   960
      End
      Begin VB.CommandButton cmdDeleteAll 
         Caption         =   "&Delete All"
         Height          =   330
         Left            =   960
         TabIndex        =   1
         Tag             =   "&Filter"
         Top             =   0
         Width           =   975
      End
      Begin VB.CommandButton cmdRefresh 
         Caption         =   "&Refresh"
         Height          =   330
         Left            =   0
         TabIndex        =   0
         Tag             =   "&Refresh"
         Top             =   0
         Width           =   855
      End
   End
   Begin MSAdodcLib.Adodc AdodcProtocols 
      Height          =   330
      Left            =   2040
      Top             =   1800
      Visible         =   0   'False
      Width           =   2295
      _ExtentX        =   4048
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Bindings        =   "frmProtocols.frx":0442
      Height          =   3375
      Left            =   120
      TabIndex        =   3
      Top             =   360
      Width           =   5895
      _ExtentX        =   10398
      _ExtentY        =   5953
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      FormatLocked    =   -1  'True
      AllowAddNew     =   -1  'True
      AllowDelete     =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   4
      BeginProperty Column00 
         DataField       =   "ID"
         Caption         =   "ID"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "MasterProtocol"
         Caption         =   "MasterProtocol"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "SlaveProtocol"
         Caption         =   "SlaveProtocol"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "Remark"
         Caption         =   "Remark"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
            ColumnWidth     =   404.787
         EndProperty
         BeginProperty Column01 
            ColumnWidth     =   2204.788
         EndProperty
         BeginProperty Column02 
            ColumnWidth     =   1920.189
         EndProperty
         BeginProperty Column03 
            ColumnWidth     =   764.787
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "frmProtocols"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub RefreshProtocols()
  With AdodcProtocols
    .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _
                        strDataPath + ";Persist Security Info=False"
    .CommandType = adCmdUnknown
    .RecordSource = "select * from Protocols order by ID"
    .Refresh
  End With
End Sub

Private Sub AdodcProtocols_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
  On Error Resume Next
  With AdodcProtocols
    If .Recordset.RecordCount > 0 Then
      .Caption = Trim(Str(.Recordset.AbsolutePosition)) + "/" + Trim(Str(.Recordset.RecordCount))
    Else
      .Caption = "0"
    End If
  End With
End Sub

Private Sub cmdAddNew_Click()
  With AdodcProtocols.Recordset
    .AddNew
  End With
End Sub

Private Sub cmdCheckProtocol_Click()
  Dim strTmp As String
  Dim strMaster As String
  On Error Resume Next
  
  With AdodcProtocols.Recordset
    If .RecordCount < 1 Then Exit Sub
    .MoveFirst
    Do While Not .EOF
      If Not IsNull(![MasterProtocol]) Then
        If False = CheckLegalChars(UCase(![MasterProtocol]), HEX_CHAR_SET) Then
          MsgBox "Error in Master Protocol!", vbCritical + vbOKOnly
          Exit Do
        End If
        
        strTmp = "(" + ![MasterProtocol] + ")"
        If InStr(1, strMaster, strTmp, vbTextCompare) <> 0 Then
          MsgBox "Redundant MasterProtocol!", vbExclamation + vbOKOnly
          Exit Sub
        Else
          strMaster = strMaster + strTmp
        End If
      End If
      
      If Not IsNull(![SlaveProtocol]) Then
        If False = CheckLegalChars(UCase(![SlaveProtocol]), HEX_CHAR_SET) Then
          MsgBox "Error in Slave Protocol!", vbCritical + vbOKOnly
          Exit Do
        End If
      End If
      .MoveNext
    Loop
    
    If .EOF Then
      .MoveLast
      MsgBox "Protocols checked OK!", vbInformation + vbOKOnly
    End If
  End With
End Sub

Private Sub cmdClose_Click()
  Unload Me
End Sub

Private Sub cmdDeleteAll_Click()
  DeleteData AdodcProtocols, 1
End Sub

Private Sub cmdRefresh_Click()
  AdjustNumber AdodcProtocols, 0
End Sub

Private Sub Form_Load()
  On Error Resume Next
  
  Call SetForm(Me, 500, 700)
  RefreshProtocols
End Sub

⌨️ 快捷键说明

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