12592 '题目:编程求一个十进制整数n的各位数字之和,设n为小于或等于5位的数。
'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()Dim N As Integer, Sum As Integer, S1 As String, S2 As StringDim i As Integer, Ch As StringSum = 0N = InputBox("输入整数n")S1 = Str(N)S1 = Trim(S1)For i = 1 To Len(S1)'**********ERROR**********Ch = Mid(N, i, 1)'**********ERROR**********Sum = Val(Ch)Next iPrint "该整数的各位数之和是:"; Sum End Sub12610'题目:程序功能根据输入的学习成绩,分别显示优秀(90分以上), 良好(75分以上),及格(60分以上)不及格四个等级.'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()ClsDim i As Integeri = InputBox("请输入学习成绩")Select Case i'**********ERROR**********Case 0 < i < 100MsgBox "成绩应该在0--100之间""" '**********ERROR**********Case 90Print "优秀"Case 75 To 89Print "良好"Case 60 To 74Print "及格"'**********ERROR**********CaseMsgBox "不及格", vbCritical End SelectEnd Sub12616.题目:求s=1!+3!+5!+7!,阶乘的计算用Function过程fact实现.'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()Dim i As Integer, s As Integer'**********ERROR**********For i = 1 To 7s = s + fact(i)Next iPrint sEnd Sub'**********ERROR**********Public Function fact()Dim t As Integer, i As Integert = 1For i = 1 To nt = t * iNext i'**********ERROR**********fact = iEnd Function12620题目:编程实现从左到右的滚动字幕,滚动的速度由滚动条控件来控制。
'------------------------------------------------ Option ExplicitPrivate Sub HScroll1_Scroll()'**********ERROR**********Timer1.Interval = HScroll1.Min - HScroll1.ValueEnd SubPrivate Sub Timer1_Timer()'**********ERROR**********If Label1.Left <= Form1.Width Then'**********ERROR**********Label1.Left = Label1.WidthElseLabel1.Left = Label1.Left + 100 End IfEnd Sub12624.题目:程序功能:求1+2+3……,直到其和超出3000为止,并输入结果。
'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()ClsDim i As IntegerDim s As Singlei = 1'**********ERROR**********s = 0Do'**********ERROR**********i = i + 2s = s + i'**********ERROR**********Loop s > 3000Print "从1 到:"; i; "的和是"; sEnd Sub12629.题目:下面的程序段用于实现以下功能:建立一顺序文件,存放10名同学的学号和三门功课成绩,显示该文件内所有记录,并同时显示其总分和平均分。
'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()Dim no%, c1%, c2%, c3%, i As Integer'**********ERROR**********Open "c:\2.txt" For Input As #1For i = 1 To 10no = InputBox("请输入学号")c1 = InputBox("请输入数学成绩")c2 = InputBox("请输入语文成绩")c3 = InputBox("请输入外语")Write #1, no, c1, c2, c2Next iClose #1'**********ERROR**********Open "c:\2.txt" For Output As #1For i = 1 To 10'**********ERROR**********Print #1, no, c1, c2, c3Print no, c1, c2, c3, c1 + c2 + c3, (c1 + c2 + c3) / 3Next iClose #1End Sub12677.题目:求s=72+102+132+……832的值。
'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()ClsDim s As LongDim i As Integer'**********ERROR**********s = 1'**********ERROR**********For i = 7 To 832s = s + i'**********ERROR**********loop 30Print sEnd Sub12683.题目:产生30个小于100的成绩随机数,并统计出优、良、中等、及格、不及格数的个数,并计算出成绩属于优秀段的成绩平均分。
'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()Dim k%, a%, bjg%, jg%, zd%, lh%, yx As IntegerDim pjf As IntegerRandomizepjf = 0For k = 1 To 30'**********ERROR**********a = Int(Rnd())Select Case aCase 0 To 59bjg = bjg + 1 '不及格Case 60 To 69jg = jg + 1 '及格Case 70 To 79zd = zd + 1 '中等Case 80 To 89lh = lh + 1 '良好Case 90 To 100yx = yx + 1 '优秀'**********ERROR**********pjf = pjf + 1End SelectNext k'**********ERROR**********If yx > 0 Then pjf = pjf / 30Debug.Print "不及格" + Str$(bjg) + "人,及格" + Str$(jg) + "人,中等" + Str$(zd) + "人";Debug.Print "良好" + Str$(lh) + "优秀" + Str$(yx) + "人"Debug.Print "优秀分数段成绩平均分" & pjfEnd Sub12687.'题目:使用顺序文件读写方式编写一个简单的记事本应用程序,' 基本逻辑是:假设在考生目录中有一个名为exam.txt的文本文件。
当点击"打开"按钮(Command1)时,程序将exam.Txt文件中的内容显示在文本框(Text1)中,当点击"新建"按钮(Command2)时,清空Text1中的内容;用户可以在Text1中进行编辑操作,当点击"保存"按钮(Command3)时,将Text1中的内容保存在exam.txt文件中。
当点击"退出"按钮(Command4)时关闭本窗体。
'------------------------------------------------ Option ExplicitPrivate Sub Command1_Click()Dim A As StringText1 = ""Open "exam.txt" For Input As #1Do While Not EOF(1)'**********ERROR**********Input #0, AText1 = Text1 + ALoop'**********ERROR**********Close #0End SubPrivate Sub Command2_Click()Text1 = ""End SubPrivate Sub Command3_Click()Open "exam.Txt" For Output As #1'**********ERROR**********Input #1, Text1Close #1End SubPrivate Sub Command4_Click()Unload MeEnd Sub12697.'题目:以下程序段用于打印如图1所示的九九乘法表:'------------------------------------------------ Option ExplicitPrivate Sub Form_Click()Dim i As Integer, j As Integer, k As IntegerPrint Tab(30); "9*9 table"Print: PrintPrint " * ";For i = 1 To 9'**********ERROR**********Print Tab(i * 6); iNext iPrintFor j = 1 To 9Print j; " ";'**********ERROR**********For k = 1 To 9'**********ERROR**********Print Tab(j * 6); j * k; " ";Next kPrintNext jEnd Sub12701.'题目:用辗转相除法求两个整数的最大公约数。