学生信息管理系统VB课程设计报告 - 图文(4)

2020-02-21 23:03

Call UpdateCell(MSFstudent.row, MSFstudent.col) Call ClearEdit End Sub

Private Sub ShowAll() Dim i As Integer For i = 1 To num

MSFstudent.TextMatrix(i, 0) = i

MSFstudent.TextMatrix(i, 1) = student(i).number MSFstudent.TextMatrix(i, 2) = student(i).Name If student(i).Birth = #12:00:00 AM# Then MSFstudent.TextMatrix(i, 3) = \ Else

MSFstudent.TextMatrix(i, 3) = student(i).Birth End If

If student(i).Sex Then

MSFstudent.TextMatrix(i, 4) = \男\ Else

MSFstudent.TextMatrix(i, 4) = \女\ End If

If student(i).Nation > 0 Then

MSFstudent.TextMatrix(i, 5) = Nation(student(i).Nation) Else

MSFstudent.TextMatrix(i, 5) = \ End If

If student(i).faculty > 0 Then

MSFstudent.TextMatrix(i, 6) = faculty(student(i).faculty) Else

MSFstudent.TextMatrix(i, 6) = \ End If

If student(i).subject > 0 Then

MSFstudent.TextMatrix(i, 7) = subject(student(i).subject) Else

MSFstudent.TextMatrix(i, 7) = \ End If

If student(i).Province > 0 Then

MSFstudent.TextMatrix(i, 8) = Province(student(i).Province) Else

MSFstudent.TextMatrix(i, 8) = \ End If

15

MSFstudent.TextMatrix(i, 9) = student(i).Score Next End Sub

Private Sub ExitEdit() EditMode = False

Call UpdateCell(MSFstudent.row, MSFstudent.col) Call ClearEdit End Sub

Private Sub UpdateCell(row As Integer, col As Integer) Select Case col Case 1, 2, 9

MSFstudent.TextMatrix(row, col) = conArr(col).Text Case 3

If conArr(col).Value = Date Then

MSFstudent.TextMatrix(row, col) = \ Else

MSFstudent.TextMatrix(row, col) = conArr(col).Value End If

Case 4 To 8

MSFstudent.TextMatrix(row, col) = conArr(col).Text End Select

Select Case col Case 1

student(row).number = conArr(col).Text Case 2

student(row).Name = conArr(col).Text Case 3

If conArr(col).Value = Date Then

student(row).Birth = #12:00:00 AM# Else

student(row).Birth = conArr(col).Value End If Case 4

If conArr(col).ListIndex = 0 Then student(row).Sex = True Else

student(row).Sex = False End If

16

Case 5

student(row).Nation = conArr(col).ListIndex + 1 Case 6

student(row).faculty = conArr(col).ListIndex + 1 Case 7

student(row).subject = conArr(col).ListIndex + 1 Case 8

student(row).Province = conArr(col).ListIndex + 1 Case 9

student(row).Score = Val(conArr(col).Text) End Select End Sub

Private Sub ClearEdit() Dim i As Integer conArr(1).Text = \ conArr(2).Text = \ conArr(9).Text = \

conArr(3).Value = #12:00:00 AM# For i = 4 To 8

conArr(i).ListIndex = -1 Next

For i = 1 To 9

conArr(i).Visible = False Next End Sub

Private Sub GetNew() Dim c As Integer For c = 1 To 9

Select Case c Case 4 To 8

With conArr(c)

Select Case c Case 4

If student(MSFstudent.row).Sex Then .ListIndex = 0 Else

.ListIndex = 1 End If

If Trim(MSFstudent.TextMatrix(MSFstudent.row, c)) = \

17

Case 5

.ListIndex = student(MSFstudent.row).Nation - 1 Case 6

.ListIndex = student(MSFstudent.row).faculty - 1 Case 7

.ListIndex = student(MSFstudent.row).subject - 1 Case 8

.ListIndex = student(MSFstudent.row).Province - 1 End Select End With

Case 3

With conArr(3)

If student(MSFstudent.row).Birth = #12:00:00 AM# Then .Value = Date Else

.Value = student(MSFstudent.row).Birth End If End With

Case 1, 2, 9

With conArr(c)

.Text = MSFstudent.Text End With End Select Next End Sub

Private Sub txtnumber_Change() Modified = True End Sub

Private Sub txtname_Change() Modified = True

End Sub

Private Sub txtscore_Change() Modified = True

End Sub 二.编辑前4个命令按钮,在编写程序时主要就是功能与算法的匹配,编写调试,

18

基本实现功能要求。删除和插入由于会影响原有的数据的序号,所以编程时使用For Next控制结构进行编写。同时因为在编写过程中我事先编写了保存数据的savedata过程,所以保存按钮的单击事件比较简单,直接调用。追加,由于是在原有数据之后进行编辑的功能,所以也比较简单。 Private Sub cmdquery_Click() frmquery.Show End Sub

Private Sub cmdappend_Click() Call ExitEdit num = num + 1

ReDim Preserve student(num) MSFstudent.Rows = num + 1

MSFstudent.TextMatrix(num, 0) = Str(num) Call GetNew Modified = True EditMode = True End Sub

Private Sub cmddelete_Click() Dim n As Integer

Dim i As Integer, j As Integer n = MSFstudent.row Call ExitEdit

If n = 0 Then Exit Sub

If MSFstudent.Rows - MSFstudent.FixedRows <= 1 Then Exit Sub MSFstudent.RemoveItem n For i = n To num - 1

student(i) = student(i + 1)

MSFstudent.TextMatrix(i, 0) = Str(i) Next

MSFstudent.Rows = num num = num - 1 If num = 0 Then Erase student Else

ReDim Preserve student(num) End If

MsgBox MSFstudent.row & \

Call GetNew Modified = True EditMode = True End Sub

19


学生信息管理系统VB课程设计报告 - 图文(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:小升初面试英语口语考题大全

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: