frmclicks.frm

来自「所在类别: 随书资源/T 工业技术/TP 自动化技术、计算机技术/TP31 计算」· FRM 代码 · 共 95 行

FRM
95
字号
VERSION 5.00
Begin VB.Form frmClicks 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "站点访问量"
   ClientHeight    =   1710
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4710
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   1710
   ScaleWidth      =   4710
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   310
      Left            =   2400
      TabIndex        =   3
      Top             =   960
      Width           =   855
   End
   Begin VB.CommandButton cmdSave 
      Caption         =   "保存"
      Height          =   310
      Left            =   1320
      TabIndex        =   2
      Top             =   960
      Width           =   855
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   1800
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   360
      Width           =   2415
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "当前站点访问量"
      Height          =   180
      Left            =   360
      TabIndex        =   0
      Top             =   480
      Width           =   1260
   End
End
Attribute VB_Name = "frmClicks"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim objCn As Connection
Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdSave_Click()
    Dim strSql$
    strSql = "Update 访问量 set user_clicks=" & Val(Text1)
    objCn.Execute strSql
    MsgBox "保存成功!"
End Sub

Private Sub Form_Load()
    Dim objRs As Recordset
    Set objCn = New Connection
     With objCn                                 '建立数据库联接
        .Provider = "SQLOLEDB"
        .ConnectionString = "User ID=sa;PWD=123;Data Source=(local);" & _
                            "Initial Catalog=图书销售"
        .Open
    End With
    '获取站点访问记录
    Set objRs = New Recordset
    With objRs
        Set .ActiveConnection = objCn
        .Open "SELECT * FROM 访问量"
        Text1 = .Fields!user_clicks
    End With
    Set objRs = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
    objCn.Close
    Set objCn = Nothing
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If Not (Chr(KeyAscii) Like "[0-9]" Or KeyAscii = vbKeyBack) Then
        KeyAscii = 0    '输入不是数字或退格键,取消输入
    End If
End Sub

⌨️ 快捷键说明

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