登录窗体:
Dim i%
Private Sub Command1_Click() If 3 – i = 1 Then
MsgBox 系统繁忙,请稍后再试!End End If
If text1 =
MsgBox 密码正确,允许登录密码正确后进入主窗体 Form1.Hide Form2.Show Else
text1 = Text2 = i = i + 1
MsgBox 密码错误!你还有 次登陆机会! ext1.SetFocus End If End Sub
Private Sub Command2_Click() //结束按钮 End End Sub
Private Sub Text2_Change()
Text2.PasswordChar = 密码显示* End Sub
主界面:
Private Sub a1_Click() //增加信息库记录 Text1.Enabled = True Text2.Enabled = True Text3.Enabled = True Text4.Enabled = True Text5.Enabled = True Command1.Enabled = True Adodc1.Recordset.AddNew End Sub
Private Sub a2_Click() //删除记录 Dim i As Integer
i = MsgBox(确实要删除吗?删除) If i = 6 Then
Adodc1.Recordset.Delete Adodc1.Recordset.MoveNext Else: Form2.Show End If
- - 10 - - - 10 -
End Sub
Private Sub a3_Click() //修改学生信息 Text1.Enabled = True Text2.Enabled = True Text3.Enabled = True Text4.Enabled = True Text5.Enabled = True Command1.Enabled = True End Sub
Private Sub b1_Click() //按课程名查找 Dim a As String
Adodc1.CommandType = adCmdUnknown
a = InputBox(请输入课程名查询窗口
Adodc1.RecordSource = 学生成绩情况 where 课程名='Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox 该课程名下没有学生!提示输入错误信息时显示 Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = 学生成绩情况Adodc1.Refresh End If End Sub
Private Sub b2_Click() //按姓名查找 Dim a As String
Adodc1.CommandType = adCmdUnknown
a = InputBox(请输入姓名查询窗口
Adodc1.RecordSource = 学生成绩情况 where 姓名='Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox 没有此姓名的学生!提示Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = 学生成绩情况Adodc1.Refresh End If End Sub
Private Sub b3_Click() //按学号查找 Dim a As String
Adodc1.CommandType = adCmdUnknown
a = InputBox(请输入学号查询窗口
Adodc1.RecordSource = 学生成绩情况 where 学号='
- - 11 - - - 11 -
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox 无该学号的学生!提示Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = 学生成绩情况Adodc1.Refresh End If End Sub
Private Sub b5_Click() // 按分数段,优秀段 Dim a As Integer
On Error GoTo ErrCode
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = 学生成绩情况 where 分数 >=90Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox 没有不及格的学生!提示Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = 学生成绩情况Adodc1.Refresh End If ErrCode: End Sub
Private Sub b6_Click() //按分数段,不及格段 Dim a As Integer
On Error GoTo ErrCode
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = 学生成绩情况 where 分数 <60Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox 没有不及格的学生!提示Adodc1.CommandType = adCmdTable
Adodc1.RecordSource = 学生成绩情况Adodc1.Refresh End If ErrCode: End Sub
Private Sub c_Click() //显示绘图界面 Form4.Show End Sub
Private Sub Command1_Click() //照片添加 Dim strb() As Byte
- - 12 - - - 12 -
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Binary As #1 fl = LOF(1) ReDim strb(fl) Get #1, , strb
Adodc1.Recordset.Fields(照片Close #1
Image1.Picture = LoadPicture(CommonDialog1.FileName) End Sub
Private Sub Command2_Click() //修改确认,增加新成员 i = MsgBox(确实要做如此改变吗?编辑) If i = vbYes Then
Adodc1.Recordset.Update Else
Adodc1.Recordset.CancelUpdate Form2.Show End If
Text1.Enabled = False Text2.Enabled = False Text3.Enabled = False Text4.Enabled = False Text5.Enabled = False Command1.Enabled = False
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = 学生成绩情况 order by 学号 asc Adodc1.Refresh End Sub
Private Sub d_Click() //打印报表 报表图.Show End Sub
Private Sub e_Click() //显示关于界面 Form3.Show End Sub
Private Sub Form_Load() End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) //工具栏 Select Case Button.Index Case 1: a1_Click Case 2: a2_Click Case 3: search_all
- - 13 - - - 13 -
Case 4: End End Select End Sub
Private Sub Toolbar1_ButtonMenuClick(ByVal ButtonMenu As MSComctlLib.ButtonMenu) Select Case Button.Index End Select End Sub
Private Sub search_all() //查看全部信息 Adodc1.CommandType = 2
Adodc1.RecordSource = 学生成绩情况Adodc1.Refresh
DataGrid1.Visible = True End Sub
统计图窗体
Dim a$(5), b%(5), max //坐标系函数 Public Sub zbx() Cls max = 0
a(1) = (2) = (3) = (4) = (5) =
Do While Not Form2.Adodc1.Recordset.EOF
Select Case Form2.Adodc1.Recordset.Fields(分数Case Is < 59 b(1) = b(1) + 1 Case 60 To 69 b(2) = b(2) + 1 Case 70 To 79 b(3) = b(3) + 1 Case 80 To 89 b(4) = b(4) + 1 Case 90 To 100 b(5) = b(5) + 1 End Select
Form2.Adodc1.Recordset.MoveNext Loop
For i = 1 To 5
If b(i) > max Then max = b(i) Next i
- - 14 - - - 14 -