📄 select1.frm
字号:
VERSION 5.00
Object = "{FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0"; "DBLIST32.OCX"
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Chapter 3.1 Example"
ClientHeight = 3330
ClientLeft = 225
ClientTop = 1815
ClientWidth = 5385
LinkTopic = "Form1"
PaletteMode = 1 'UseZOrder
ScaleHeight = 3330
ScaleWidth = 5385
Begin VB.CommandButton cmdClose
Caption = "&Close"
Default = -1 'True
Height = 525
Left = 4050
TabIndex = 2
Top = 2730
Width = 1245
End
Begin VB.ListBox lstTitles
Height = 1035
Left = 120
TabIndex = 1
Top = 1560
Width = 5175
End
Begin VB.Data dtaData
Caption = "dtaData"
Connect = "Access"
DatabaseName = "D:\Program Files\Microsoft Visual Studio\VB6\Biblio.MDB"
DefaultCursorType= 0 'DefaultCursor
DefaultType = 2 'UseODBC
Exclusive = 0 'False
Height = 345
Left = 120
Options = 0
ReadOnly = 0 'False
RecordsetType = 2 'Snapshot
RecordSource = "SELECT [Company Name] FROM [Publishers] WHERE [State] = 'NY' ORDER BY [Company Name]"
Top = 1170
Visible = 0 'False
Width = 2115
End
Begin MSDBCtls.DBList dlstPublishers
Bindings = "Select1.frx":0000
Height = 1035
Left = 120
TabIndex = 0
Top = 90
Width = 5175
_ExtentX = 9128
_ExtentY = 1826
_Version = 327680
MatchEntry = -1 'True
BackColor = -2147483643
ListField = "Company Name"
BoundColumn = ""
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Change the following to point to your copy of BIBLIO.MDB.
Private Const BIBLIO_PATH = "D:\Program Files\Microsoft Visual Studio\VB6\Biblio.MDB"
Private Sub Form_Load()
Dim dbfBiblio As Database, recSelect As Recordset
Dim strSQL As String
'Set up the error handler.
On Error GoTo FormLoadError
'Get the database name & open the database.
dtaData.DatabaseName = BIBLIO_PATH
dtaData.Refresh
Set dbfBiblio = DBEngine.Workspaces(0).OpenDatabase(BIBLIO_PATH)
'Open a snapshot-type recordset on the [Titles] table, selecting only
'those titles published in 1993 or 1994, sorting by the ISBN number.
'Note the use of the line continuation character (_) to make the
'code more readable, and is used throughout all of the examples.
strSQL = "SELECT [Title], [ISBN] FROM [Titles] " & _
"WHERE [Year Published] = 1993 Or [Year Published] = 1994 " & _
"ORDER BY [ISBN]"
'Create the recordset.
Set recSelect = dbfBiblio.OpenRecordset(strSQL, dbOpenSnapshot)
'Iterate through the recordset until the end of the file (EOF) is
'reached. Display each record in the unbound list box lstTitles.
If recSelect.RecordCount > 0 Then
recSelect.MoveFirst
Do Until recSelect.EOF
lstTitles.AddItem recSelect![ISBN] & ": " & recSelect![Title]
recSelect.MoveNext
Loop
End If
Exit Sub
FormLoadError:
'If an error occurs, display it with a MsgBox command.
MsgBox Err.Description, vbExclamation
Exit Sub
End Sub
Private Sub cmdClose_Click()
'End the program
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -