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

📄 frmarea.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 frmArea 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "区域信息"
   ClientHeight    =   3615
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   4620
   Icon            =   "frmArea.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   3615
   ScaleWidth      =   4620
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdDel 
      Caption         =   "删除"
      Enabled         =   0   'False
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1320
      TabIndex        =   5
      Top             =   3120
      Width           =   735
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Bindings        =   "frmArea.frx":030A
      Height          =   2055
      Left            =   120
      TabIndex        =   8
      TabStop         =   0   'False
      ToolTipText     =   "选择所在行修改区域名称"
      Top             =   240
      Width           =   4335
      _ExtentX        =   7646
      _ExtentY        =   3625
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   22
      FormatLocked    =   -1  'True
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   "Code"
         Caption         =   "代码"
         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       =   "Name"
         Caption         =   "区域名称"
         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     =   900.284
         EndProperty
         BeginProperty Column01 
            ColumnWidth     =   2670.236
         EndProperty
      EndProperty
   End
   Begin VB.TextBox txtCode 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   720
      MaxLength       =   2
      TabIndex        =   0
      ToolTipText     =   "两位数字(1-99)"
      Top             =   2520
      Width           =   615
   End
   Begin MSAdodcLib.Adodc AdodcCaller 
      Height          =   330
      Left            =   1080
      Top             =   0
      Visible         =   0   'False
      Width           =   1200
      _ExtentX        =   2117
      _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 VB.CommandButton cmdQuit 
      Caption         =   "退出"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2520
      TabIndex        =   3
      Top             =   3120
      Width           =   735
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确认"
      Default         =   -1  'True
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3720
      TabIndex        =   2
      ToolTipText     =   "修改或增加"
      Top             =   3120
      Width           =   735
   End
   Begin VB.CommandButton cmdClear 
      Caption         =   "清除"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   4
      Top             =   3120
      Width           =   735
   End
   Begin VB.TextBox txtName 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2520
      MaxLength       =   10
      TabIndex        =   1
      ToolTipText     =   "不超过10个汉字"
      Top             =   2520
      Width           =   1935
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "代码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   7
      Top             =   2640
      Width           =   615
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "区域名称"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1440
      TabIndex        =   6
      Top             =   2640
      Width           =   1095
   End
End
Attribute VB_Name = "frmArea"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdClear_Click()
    txtCode.Text = ""
    txtName.Text = ""
End Sub

Private Sub cmdDel_Click()
    Dim nTmp As Integer
    Dim nRet As Integer
    On Error Resume Next 'CallerID
    
    
    With AdodcCaller.Recordset
        If .EOF Or .BOF Or .RecordCount < 1 Then
            cmdDel.Enabled = False
            Exit Sub
        End If
        
        nTmp = ![Code]
        nRet = MsgBox("确信删除代码为:" + Trim(Str(nTmp)) + " 的记录吗?", vbQuestion + vbYesNo, "提示")
        If nRet = 6 Then
            .Delete
            .Requery
             AdjustNumber AdodcCaller, 1
        End If
    End With
End Sub

Private Sub cmdOK_Click()
    Dim nTmp As Integer
    Dim bAddNew As Boolean
    On Error Resume Next 'CallerID
    
    
    nTmp = Val(txtCode.Text)
    If nTmp < 1 Or nTmp > 99 Then
        MsgBox "代码必须在1至99之间!", vbQuestion + vbOKOnly, "提示"
        txtCode.SetFocus
        Exit Sub
    End If
    
    If Len(txtName.Text) < 2 Then
        MsgBox "区域名称的长度至少两个字以上!", vbQuestion + vbOKOnly, "提示"
        txtName.SetFocus
        Exit Sub
    End If
    
    With AdodcCaller.Recordset
        If .RecordCount < 1 Then
            bAddNew = True
        Else
            .MoveFirst
            Do While Not .EOF
                If ![Code] = nTmp Then Exit Do
                .MoveNext
            Loop
                    
            If .EOF Then bAddNew = True
        End If
        
        On Error GoTo END_MARK
        If bAddNew = True Then .AddNew
        ![Code] = nTmp
        ![Name] = Trim(txtName.Text)
        .Update
        .Requery
    End With
    
    frmMain.GetCorpInfo
END_MARK:
End Sub

Private Sub cmdQuit_Click()
    Unload Me
End Sub

Private Sub DataGrid1_Click()
    On Error Resume Next 'CallerID
    
    With AdodcCaller.Recordset
        If (.RecordCount > 0) And (Not (.EOF Or .BOF)) Then
            txtCode.Text = ![Code]
            txtName.Text = ![Name]
            cmdDel.Enabled = True
        Else
            cmdDel.Enabled = False
        End If
    End With
End Sub

Private Sub Form_Load()
    On Error Resume Next 'CallerID
    
    SetWindowPos frmArea.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE

    With AdodcCaller
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _
                          strDataPath + ";Persist Security Info=False"
        .CommandType = adCmdUnknown
        .RecordSource = "select * from Area order by [Code]"
        .Refresh
        
        If .Recordset.RecordCount > 0 Then
            cmdDel.Enabled = True
        Else
            cmdDel.Enabled = False
        End If
    End With
End Sub

Private Sub Form_Unload(Cancel As Integer)
    AdjustNumber AdodcCaller, 1
End Sub

⌨️ 快捷键说明

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