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

📄 form1.frm

📁 VISUAL BASIC 中
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4455
   ClientLeft      =   1620
   ClientTop       =   1545
   ClientWidth     =   5985
   LinkTopic       =   "Form1"
   ScaleHeight     =   4455
   ScaleWidth      =   5985
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   480
      TabIndex        =   15
      Top             =   1080
      Width           =   1215
   End
   Begin VB.ComboBox cboName 
      Height          =   315
      ItemData        =   "Form1.frx":0000
      Left            =   720
      List            =   "Form1.frx":0010
      Style           =   2  'Dropdown List
      TabIndex        =   12
      Top             =   600
      Width           =   1215
   End
   Begin VB.CommandButton cmdCount 
      Caption         =   "查询"
      Height          =   495
      Left            =   600
      TabIndex        =   10
      Top             =   1680
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "Label4"
      Height          =   495
      Left            =   3840
      TabIndex        =   18
      Top             =   3000
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "Label3"
      Height          =   255
      Left            =   2640
      TabIndex        =   17
      Top             =   3000
      Width           =   975
   End
   Begin VB.Label Label2 
      Caption         =   "Label2"
      Height          =   375
      Left            =   1440
      TabIndex        =   16
      Top             =   2880
      Width           =   1095
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "合计"
      Height          =   255
      Index           =   7
      Left            =   2040
      TabIndex        =   14
      Top             =   2040
      Width           =   495
   End
   Begin VB.Label lblCountTotal 
      BorderStyle     =   1  'Fixed Single
      Height          =   255
      Left            =   2880
      TabIndex        =   13
      Top             =   2040
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "姓名"
      Height          =   255
      Index           =   6
      Left            =   120
      TabIndex        =   11
      Top             =   600
      Width           =   495
   End
   Begin VB.Label lblCountO 
      BorderStyle     =   1  'Fixed Single
      Height          =   255
      Left            =   2880
      TabIndex        =   9
      Top             =   1680
      Width           =   495
   End
   Begin VB.Label lblCountF 
      BorderStyle     =   1  'Fixed Single
      Height          =   255
      Left            =   2880
      TabIndex        =   8
      Top             =   1320
      Width           =   495
   End
   Begin VB.Label lblCountC 
      BorderStyle     =   1  'Fixed Single
      Height          =   255
      Left            =   2880
      TabIndex        =   7
      Top             =   960
      Width           =   495
   End
   Begin VB.Label lblCountP 
      BorderStyle     =   1  'Fixed Single
      Height          =   255
      Left            =   2880
      TabIndex        =   6
      Top             =   600
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "O"
      Height          =   255
      Index           =   5
      Left            =   2040
      TabIndex        =   5
      Top             =   1680
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "F"
      Height          =   255
      Index           =   4
      Left            =   2040
      TabIndex        =   4
      Top             =   1320
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "C"
      Height          =   255
      Index           =   3
      Left            =   2040
      TabIndex        =   3
      Top             =   960
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "P"
      Height          =   255
      Index           =   2
      Left            =   2040
      TabIndex        =   2
      Top             =   600
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "数量"
      Height          =   255
      Index           =   1
      Left            =   2880
      TabIndex        =   1
      Top             =   240
      Width           =   495
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "等级"
      Height          =   255
      Index           =   0
      Left            =   2040
      TabIndex        =   0
      Top             =   240
      Width           =   495
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

' Make some random test data.
Private Sub MakeData()
Dim dbString As String
Dim db As Database
Dim query As String
Dim i As Integer
Dim names(0 To 3) As String
Dim statuses(0 To 3) As String
Dim new_name As String
Dim new_status As String
Dim new_amount As Currency

    ' Open the database.
    dbString = App.Path & "\sales.mdb"
    Set db = OpenDatabase(dbString)
    
    ' Make the random data.
    statuses(0) = "P"
    statuses(1) = "C"
    statuses(2) = "F"
    statuses(3) = "O"
    names(0) = "Remkus"
    names(1) = "Stephens"
    names(2) = "Johnson"
    names(3) = "Smythe"
    
    Randomize
    For i = 1 To 50
        new_name = names(Int(Rnd * 4))
        new_status = statuses(Int(Rnd * 4))
        new_amount = 50 + Rnd * 1000
        query = "INSERT INTO sales Values(" & _
            "'" & new_name & "', " & _
            "'" & new_status & "', " & _
            new_amount & ")"
        db.Execute query
    Next i
    
    db.Close
End Sub

Private Sub cmdCount_Click()
Dim dbString As String
Dim db As Database
Dim rs As Recordset
Dim lstrSQL As String

    lstrSQL = ""
    lstrSQL = lstrSQL & "Select Count(*) as TotalCount, "
    lstrSQL = lstrSQL & "Count(iif([status] = 'P', 1, null)) as PCount, "
    lstrSQL = lstrSQL & "Count(iif([status] = 'C', 1, null)) as CCount, "
    lstrSQL = lstrSQL & "Count(iif([status] = 'F', 1, null)) as FCount, "
    lstrSQL = lstrSQL & "Count(iif([status] = 'O', 1, null)) as OCount "
    lstrSQL = lstrSQL & "From Sales "
    lstrSQL = lstrSQL & "Where [Employee] = '" & _
        cboName.Text & "'"

    dbString = App.Path & "\sales.mdb"
    Set db = OpenDatabase(dbString)
    
    ' Execute the query.
    Set rs = db.OpenRecordset(lstrSQL, dbOpenSnapshot)

    ' Display the results.
    lblCountTotal.Caption = Format$(rs(0))
    lblCountP.Caption = Format$(rs(1))
    lblCountC.Caption = Format$(rs(2))
    lblCountF.Caption = Format$(rs(3))
    lblCountO.Caption = Format$(rs(4))

    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

End Sub

Private Sub Command1_Click()



Dim dbString As String
Dim db As Database
Dim rs As Recordset
Dim lstrSQL As String


Dim dbString1 As String
Dim db1 As Database

Dim rs1 As Recordset
Dim lstrSQL1 As String
    
    
    
    
    
    lstrSQL = "SELECT date,time,m1 FROM Leitou WHERE Id=10"
    dbString = App.Path & "\csjl-97.mdb"
    Set db = OpenDatabase(dbString)
    ' Execute the query.
    Set rs = db.OpenRecordset(lstrSQL, dbOpenSnapshot)
    
    
    
    lstrSQL1 = "SELECT date,time,m1 FROM Biao_temp"
    dbString1 = App.Path & "\csjl_temp-97.mdb"
    Set db1 = OpenDatabase(dbString1, , True)
    ' Execute the query.
    Set rs1 = db1.OpenRecordset(lstrSQL1, dbOpenSnapshot)
    
     
       
    'rs1("m1") = rs("m1")
    

    ' Display the results.
    Label2.Caption = Format$(rs("M1"))
'     Label3.Caption = Format$(rs("amount"))
'    Label4.Caption = Format$(rs("employee"))

rs1.MoveFirst

rs1.Edit
rs1("M1") = Label2.Caption
rs1.Update





    rs.Close
    db.Close
    Set rs = Nothing
    Set db = Nothing

  rs1.Close
    db1.Close
    Set rs1 = Nothing
    Set db1 = Nothing





End Sub

Private Sub Form_Load()
    ' Uncomment the following to make some random data.
    ' MakeData
    ' End
    
    cboName.ListIndex = 0
End Sub

⌨️ 快捷键说明

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