VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2520
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4185
   LinkTopic       =   "Form1"
   ScaleHeight     =   2520
   ScaleWidth      =   4185
   StartUpPosition =   3  '窗口缺省
   Begin VB.TextBox Text2 
      Height          =   435
      Left            =   3060
      TabIndex        =   3
      Text            =   "990102"
      Top             =   600
      Width           =   1035
   End
   Begin VB.CommandButton Command2 
      Caption         =   "查看"
      Height          =   315
      Left            =   3060
      TabIndex        =   2
      Top             =   1800
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "写入"
      Height          =   315
      Left            =   3060
      TabIndex        =   1
      Top             =   1320
      Width           =   975
   End
   Begin VB.TextBox Text1 
      Height          =   2055
      Left            =   60
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   60
      Width           =   2895
   End
   Begin VB.Data Data1 
      Align           =   2  'Align Bottom
      Caption         =   "Data1"
      Connect         =   "Access"
      DatabaseName    =   ""
      DefaultCursorType=   0  '缺省游标
      DefaultType     =   2  '使用 ODBC
      Exclusive       =   0   'False
      Height          =   345
      Left            =   0
      Options         =   0
      ReadOnly        =   0   'False
      RecordsetType   =   1  'Dynaset
      RecordSource    =   "Student"
      Top             =   2175
      Width           =   4185
   End
   Begin VB.Label Label1 
      Caption         =   "指定学号"
      Height          =   255
      Left            =   3120
      TabIndex        =   4
      Top             =   300
      Width           =   855
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    no = Text2
    Open "mydb.txt" For Output As #1
    Data1.RecordSource = "Select 学号,学期,课程名,成绩 From Class Where Class.学号='" + no + "'"
    Data1.Refresh
    Do While Not Data1.Recordset.EOF
        no = Data1.Recordset.Fields("学号")
        kc = Data1.Recordset.Fields("课程名")
        cj = Data1.Recordset.Fields("成绩")
        xq = Data1.Recordset.Fields("学期")
        Print #1, no, kc, cj, xq
        Data1.Recordset.MoveNext
    Loop
    Close #1
End Sub

Private Sub Command2_Click()
    Text1 = ""
    Open "mydb.txt" For Input As #1
    Do While Not EOF(1)
        Line Input #1, ms
        Text1 = Text1 & ms & vbCrLf
    Loop
    Close #1
End Sub

Private Sub Form_Load()
    '可以在设计时设定
    Data1.DatabaseName = "mydb.mdb"
    Data1.RecordSource = "student"
    Data1.Refresh
End Sub
