第一套
第一题:
Private Sub Command1_Click()
TxtWelCome.Value = "欢迎使用VBA!"
End Sub
第二题:
Private Sub Command1_Click()
''' 不得删除本行注释
Dim s%, i%, M%, N%
M = Text1.Value
N = Text2.Value
s = 0
For i = M To N
s = s + i
Next
Label1.Caption = s
End Sub
第三题:
Private Sub Command1_Click()
''' 不得删改本行注释
Dim rs As ADODB.Recordset
Dim strSQL As String
Set rs = New ADODB.Recordset
strSQL = "Select * from course where 课程编号='" & Text1.Value & "'" '本行需要补充代码
rs.Open strSQL, CurrentProject.Connection, 2, 2 '本行需要补充代码
If rs.EOF Then
rs.AddNew
rs("课程编号") = Text1
rs("课程名称") = Text2
rs("学时") = Text3
rs("学分") = Text4 '本行需要补充代码
rs.Update
End If
rs.Close
Set rs = Nothing
End Sub
第二套
第一题:
Private Sub Command1_Click()
''' 不得删除本行注释
Label1.Visible = True
End Sub
Private Sub Command2_Click()
''' 不得删除本行注释
Label1.Visible = False
End Sub
第二题:
Private Sub Command1_Click()
''' 不得删除本行注释
Dim x As Integer, y As Integer, z As Integer
x = Text1.Value
y = Text2.Value
If Frame1.Value = 1 Then
z = x + y
ElseIf Frame1.Value = 2 Then
z = x - y
Else
z = x * y
End If
Label6.Caption = z
End Sub
第三题:
Private Sub Command1_Click()
'成绩等级评定
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset '本行需补充代码
rs.Open "select * from 学生", CurrentProject.Connection, 2, 2
Do While Not rs.EOF() '本行需补充代码
Select Case rs("综合分")
Case Is >= 90
rs("等级") = "优秀"
Case Is >= 80
rs("等级") = "良好" '本行需补充代码
Case Is >= 70
rs("等级") = "中等"
Case Is >= 60
rs("等级") = "及格"
Case Else
rs("等级") = "不及格" '本行需补充代码
End Select
rs.Update '本行需补充代码
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
等级评定