《求1到100之间所有偶数之和.docx》由会员分享,可在线阅读,更多相关《求1到100之间所有偶数之和.docx(3页珍藏版)》请在三一办公上搜索。
1、求1到100之间所有偶数之和1、求1到100之间所有偶数的和。Private Sub Command1_ClickDim i As Integer, sum As Integersum = 0For i = 2 To 100 Step 2sum = sum + iNext iPrint sumEnd Sub2、设计一个程序,程序名为“PRG2,功能是根据分数>=90,>=80,>=60,<60,返回优秀,良好,及格,不及格。Private Sub Command1_ClickDim grade As Single, result As Stringgrade = Val(Inp
2、utBox(请输入成绩:, 成绩输入)Select Case gradeCase Is >= 90result = 优秀Case Is >= 80result = 良好Case Is >= 60result = 及格Case Is < 60result = 不及格End SelectMsgBox 该生的成绩等级为: & result, , 成绩等级End Sub或者Private Sub Command1_ClickText1.SetFocusa = Val(Text1.Text)If Text1.Text <> ThenIf a >= 90 And a <= 100 ThenPrint 优秀ElseIf a >= 80 And a < 90 ThenPrint 良好ElseIf a >= 70 And a < 80 ThenPrint 一般ElseIf a >= 60 And a < 70 ThenPrint 及格Else: Print 不及格End IfElseMsgBox 请输入学生成绩, 0 + 32, 错误!End IfEnd SubPrivate Sub Form_LoadText1.Text = End Sub