📄 form1.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form Form1
Caption = "Chapter 3.10 Example"
ClientHeight = 3705
ClientLeft = 60
ClientTop = 345
ClientWidth = 5865
LinkTopic = "Form1"
ScaleHeight = 3705
ScaleWidth = 5865
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdClose
Caption = "Close"
Height = 525
Left = 4500
TabIndex = 1
Top = 3060
Width = 1245
End
Begin MSFlexGridLib.MSFlexGrid grdValues
Height = 2565
Left = 120
TabIndex = 0
Top = 360
Width = 5655
_ExtentX = 9975
_ExtentY = 4524
_Version = 393216
Cols = 3
ScrollBars = 2
AllowUserResizing= 1
End
Begin VB.Label lblPublishers
Caption = "Publisher Names"
Height = 225
Left = 150
TabIndex = 2
Top = 90
Width = 1245
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const BIBLIO_PATH = "D:\Program Files\Microsoft Visual Studio\VB6\Biblio.MDB"
Private Sub cmdClose_Click()
End
End Sub
Private Sub Form_Load()
Dim dbfBiblio As Database, recSelect As Recordset
Dim strSQL As String
Dim intCount As Integer, intGridRow As Integer
Set dbfBiblio = DBEngine.Workspaces(0).OpenDatabase(BIBLIO_PATH)
' Build the query, starting with its SELECT statement.
' Note the LCase() function; a VBA function, NOT an SQL function.
strSQL = "SELECT Publishers.PubID, Publishers.Name, " & _
"LCase([Publishers].[Name]) AS CheckedName " & _
"FROM Publishers;"
' Run the query to create the recordset.
Set recSelect = dbfBiblio.OpenRecordset(strSQL, dbOpenSnapshot)
' Make sure the query returned at least one record
If recSelect.RecordCount > 0 Then
'Get the record count & display it on the form
recSelect.MoveLast
intCount = recSelect.RecordCount
lblPublishers.Caption = "Publisher Names (" & CStr(intCount) & "records)"
'Initialize the grid
With grdValues
.Rows = intCount + 1
.ColWidth(0) = 700: .ColWidth(1) = 2000: .ColWidth(2) = 4000
.Row = 0: .Col = 0: .Text = "Pub ID"
.Col = 1: .Text = "Name"
.Col = 2: .Text = "Name After LCase()"
End With
'Populate the grid
recSelect.MoveFirst
For intGridRow = 1 To intCount
With grdValues
.Row = intGridRow
.Col = 0: .Text = recSelect![PubID]
.Col = 1: .Text = recSelect![Name]
.Col = 2: .Text = recSelect![CheckedName]
End With
recSelect.MoveNext
Next intGridRow
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -