VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form Form1 
   Caption         =   "VB6 例11-12d 使用对象变量访问数据库"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6165
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   6165
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text1 
      Height          =   270
      Left            =   4560
      TabIndex        =   3
      Text            =   "5"
      Top             =   2460
      Width           =   420
   End
   Begin MSComCtl2.UpDown UpDown1 
      Height          =   270
      Left            =   5040
      TabIndex        =   2
      Top             =   2460
      Width           =   270
      _ExtentX        =   476
      _ExtentY        =   476
      _Version        =   393216
      Value           =   5
      BuddyControl    =   "Text1"
      BuddyDispid     =   196609
      OrigLeft        =   5040
      OrigTop         =   2460
      OrigRight       =   5310
      OrigBottom      =   2730
      Max             =   25
      Min             =   5
      Enabled         =   -1  'True
   End
   Begin VB.CommandButton Command2 
      Caption         =   "下 页"
      Height          =   375
      Left            =   2700
      TabIndex        =   1
      Top             =   2400
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "上 页"
      Height          =   375
      Left            =   720
      TabIndex        =   0
      Top             =   2400
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "每页"
      Height          =   300
      Left            =   4080
      TabIndex        =   4
      Top             =   2460
      Width           =   495
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
    Dim db As Database, rs As Recordset
    Dim book As String
Private Sub Command1_Click()
    rs.Bookmark = book
    i = Val(Text1)
    Do While Not rs.BOF And i > 0
    rs.MovePrevious
    i = i - 1
    Loop
    If rs.BOF Then rs.MoveFirst
    Command2_Click
End Sub

Private Sub Command2_Click()
    Cls
    Print "学  号        姓  名       性别           出生日期      专业"
    book = rs.Bookmark
    i = 0
    Do While Not rs.EOF And i < Val(Text1)
    Print rs.Fields("学号"), rs.Fields("姓名"), rs.Fields("性别"), rs.Fields("出生年月"), rs.Fields("专业")
    rs.MoveNext
    i = i + 1
    Loop
    If rs.EOF Then rs.Bookmark = book
End Sub

Private Sub Form_Initialize()
    mpath = App.Path
    If Right(mpath, 1) <> "\" Then mpath = mpath + "\"
    Set db = OpenDatabase(mpath + "Student.mdb")   ' 打开数据库
    Set rs = db.OpenRecordset("基本情况")       ' 设置记录集
    book = rs.Bookmark
End Sub

Private Sub UpDown1_DownClick()
    If Val(Text1) > 5 Then Text1 = Val(Text1) - 1
End Sub

Private Sub UpDown1_UpClick()
    Text1 = Val(Text1) + 1
End Sub
