收藏 分销(赏)

VB-阅读题及答案.doc

上传人:仙人****88 文档编号:11731592 上传时间:2025-08-11 格式:DOC 页数:32 大小:223.50KB 下载积分:10 金币
下载 相关 举报
VB-阅读题及答案.doc_第1页
第1页 / 共32页
VB-阅读题及答案.doc_第2页
第2页 / 共32页


点击查看更多>>
资源描述
<p>选择结构 1. 在窗体上画一个名称为Command1的命令按钮和两个名称分别为Text1、Text2的文本框,然后编写如下事件过程: Private Sub Command1_Click() n=Text1.Text Select Case n Case 1 To 20 x=10 Case 2, 4, 6 x=20 Case Is&lt;10 1=&quot;&quot; 3=&quot;&quot; 10=&quot;&quot; x=&quot;&quot; case=&quot;&quot; end=&quot;&quot; select=&quot;&quot; text2.text=&quot;x&quot; sub=&quot;&quot; 2.=&quot;&quot; private=&quot;&quot; if=&quot;&quot; then=&quot;&quot; y=&quot;&quot; else=&quot;&quot; print=&quot;&quot; 3.=&quot;&quot; is=&quot;&quot;&gt;4 Print &quot;分支 2&quot; Case Else Print &quot;Else 分支 &quot; End Select End Sub 程序运行后,如果在输入对话框中输入2,则窗体上显示的是 &nbsp; &nbsp; &nbsp;Else分支 4. 在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程: Private Sub Command1_Click() A = 75 If A &gt; 60 Then &nbsp;I = 1 ElseIf A &gt; 70 Then &nbsp;I = 2 ElseIf A &gt; 80 Then &nbsp;I = 3 ElseIf A &gt; 90 Then &nbsp;I = 4 End If Print &quot;I=&quot;; I End Sub 程序运行后,单击命令按钮,窗体上显示的是 &nbsp; &nbsp;1 5. 阅读下列程序,写出运行结果。 &nbsp; &nbsp;Private Sub Command1_Click() Dim x As Integer, s As Integer x = Val(InputBox(&quot;请输入一个正整数&quot;)) If x &lt; 5 Then &nbsp; &nbsp;s =x * x Else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = x + x End If Text1.Text = Str(s) End Sub 程序运行时连续三次单击Command1,且设输入的数是5,2和4时,分别写出文本框text1.text的值。 10 4 16 6. 阅读程序 Private Sub Form_Click() &nbsp; Dim strC As String*1 &nbsp; strC=InputBox(&quot;请输入数据&quot;) &nbsp; Select Case strC &nbsp; &nbsp; &nbsp;Case &quot;a&quot; To &quot;z&quot;,&quot;A&quot; To &quot;Z&quot; &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Alpha Character&quot; &nbsp; &nbsp; &nbsp;Case &quot;0&quot; To &quot;9&quot; &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Numeral Character&quot; &nbsp; &nbsp; &nbsp;Case Else &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Other Character&quot; &nbsp; &nbsp;End Select End Sub 设输入的数据为“W”时,单击窗体后,窗体上显示是什么? W Is Alpha Character 7. 阅读程序 Private Sub Form_Click() &nbsp; Dim strC As String*1 &nbsp; strC=InputBox(&quot;请输入数据&quot;) &nbsp; Select Case strC &nbsp; &nbsp; &nbsp;Case &quot;a&quot; To &quot;z&quot;,&quot;A&quot; To &quot;Z&quot; &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Alpha Character&quot; &nbsp; &nbsp; &nbsp;Case &quot;0&quot; To &quot;9&quot; &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Numeral Character&quot; &nbsp; &nbsp; &nbsp;Case Else &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Other Character&quot; &nbsp; &nbsp;End Select End Sub 设输入的数据为“8”时,单击窗体后,窗体上显示是什么? 8 Is Numeral Character 8. 阅读程序 Private Sub Form_Click() &nbsp; Dim strC As String*1 &nbsp; strC=InputBox(&quot;请输入数据&quot;) &nbsp; Select Case strC &nbsp; &nbsp; &nbsp;Case &quot;a&quot; To &quot;z&quot;,&quot;A&quot; To &quot;Z&quot; &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Alpha Character&quot; &nbsp; &nbsp; &nbsp;Case &quot;0&quot; To &quot;9&quot; &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Numeral Character&quot; &nbsp; &nbsp; &nbsp;Case Else &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print strC+&quot; Is Other Character&quot; &nbsp; &nbsp;End Select End Sub 设输入的数据为“?”时,单击窗体后,窗体上显示是什么? ? Is Other Character 9. 阅读程序 Private Sub Form_Click() A=1:I=0 SELECT &nbsp;CASE &nbsp;A*2 CASE 1 &nbsp; &nbsp;A=A+1 CASE 2 &nbsp; &nbsp;A=A+2 CASE ELSE &nbsp; &nbsp;A=A+3 END SELECT Print A End Sub 单击窗体后,窗体上显示是什么? &nbsp;3 10. 执行如下程序段,输出结果为: x=2 If x&gt;=3 Then A=3 If x&gt;=2 Then A=2 If x&gt;=1 Then A=1 Print A 1 11. 下列程序段的执行结果为 A=1:B=0 Select Case A Case 1 Select Case B Case 0 Print &quot;**O**&quot; Case 1 Print &quot;**1**&quot; End Select Case 2 Print &quot;**2**&quot; End Select **O** 12. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As Integer, b As Integer a = Int(Rnd() + 1) Select Case a Case 1 &nbsp; Print &quot;****&quot; Case 2 &nbsp; Print &quot;####&quot; Case Else &nbsp; Print &quot;@@@@&quot; End Select End Sub **** 13. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As Integer, b As Integer a = Sgn(-10) Select Case a Case &nbsp;1 &nbsp; Print &quot;****&quot; Case &nbsp;-1 &nbsp; Print &quot;####&quot; Case Else &nbsp; Print &quot;@@@@&quot; End Select End Sub #### 14. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As Integer, b As Integer a = Sgn(-10) Select Case a Case &nbsp;1 &nbsp; Print &quot;****&quot; Case &nbsp;2 &nbsp; Print &quot;####&quot; Case Else &nbsp; Print &quot;@@@@&quot; End Select End Sub @@@@ 15. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As String, b As Integer, c As String c = 0 a = InputBox(&quot;输入第1个数据:&quot;) b = InputBox(&quot;输入第2个数据:&quot;) If a &gt; b Then c = Int(-11.99) + Int(-100 Mod 7) * Sgn(Rnd() * 100) Else &nbsp;c = 3 ^ 3 \ 3 * 3 End If Print c End Sub 设输入的数据分别为“-3”和“-4”时,单击后,窗体上显示是什么? -14 16. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As String, b As Integer, c As String c = 0 a = InputBox(&quot;输入第1个数据:&quot;) b = InputBox(&quot;输入第2个数据:&quot;) If a &gt; b Then c = Int(-11.99) + Int(-100 Mod 7) * Sgn(Rnd() * 100) Else &nbsp;c = 3 ^ 3 \ 3 * 3 End If Print c End Sub 设输入的数据分别为“5”和“7”时,单击后,窗体上显示是什么? 3 17. 阅读程序 Private Sub Command1_Click() Dim a As String, b As Integer, c As String c = 0 a = InputBox(&quot;输入第1个数据:&quot;) b = InputBox(&quot;输入第2个数据:&quot;) If a &gt; b Then c = Int(-9.45) + Int(-100 Mod 3) * Sgn(Rnd() * -100) Else &nbsp;c = 3 ^ 3 \ 3 * 3 + a ^ 3 End If Print c End Sub 输入的数据分别为“5”和“7”时,单击后,窗体上显示是什么? 128 18. 阅读程序 Private Sub Command1_Click() Dim a As String, b As Integer, c As String c = 0 a = InputBox(&quot;输入第1个数据:&quot;) b = InputBox(&quot;输入第2个数据:&quot;) If a &gt; b Then c = Int(-9.45) + Int(-100 Mod 3) * Sgn(Rnd() * -100) Else &nbsp;c = 3 ^ 3 \ 3 * 3 + a ^ 3 End If Print c End Sub设输入的数据分别为“7”和“5”时,单击后,窗体上显示是什么? -9 19. 阅读程序 Private Sub Command1_Click() Dim x As Single, y As Single, s As String s = &quot;1234&quot; x = Right(s, 1) Select Case x Case Is &lt;= 1=&quot;&quot; 2=&quot;&quot; 3=&quot;&quot; y=&quot;4&quot; x=&quot;&quot; case=&quot;&quot; to=&quot;&quot; mod=&quot;&quot; is=&quot;&quot;&gt; 3 &nbsp;y = (5 * x + 1) \ (6 * x - 8) End Select Print y End Sub 单击后,窗体上显示是什么? 1 20. 阅读程序 Private Sub Command1_Click() Dim x As Single, y As Single, s As String s = &quot;1234&quot; x = left(s, 1) Select Case x Case Is &lt;= 1=&quot;&quot; 2=&quot;&quot; 3=&quot;&quot; y=&quot;4&quot; x=&quot;&quot; case=&quot;&quot; to=&quot;&quot; mod=&quot;&quot; is=&quot;&quot;&gt; 3 &nbsp;y = (5 * x + 1) \ (6 * x - 8) End Select Print y End Sub 单击后,窗体上显示是什么? 0 21. 阅读下列程序,写出运行结果。 &nbsp; &nbsp;Private Sub Command1_Click() Dim x As Integer, s As Integer x = Val(InputBox(&quot;请输入一个正整数&quot;)) If x &gt; 5 Then &nbsp; &nbsp;s =sqr(x) Else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s =asb(x) + x End If Text1.Text = Str(s) End Sub 程序运行时连续三次单击Command1,且设输入的数是16,5和-1时,分别写出文本框text1.text的值。 4 10 0 22. 阅读程序 Private Sub Command1_Click() Dim x, a, b, c As Integer Dim b1, b2 As Boolean x = 10: a = 1: b = 2: b1 = -5: b2 = 0 If a &lt; b Then If b &lt;&gt; 3 Then &nbsp;If Not b1 Then &nbsp; x = -10 &nbsp; Else &nbsp; &nbsp;If b2 Then x = -30 &nbsp; &nbsp; x = -50 &nbsp; &nbsp; End If &nbsp; &nbsp;End If End If Print x End Sub 单击命令按钮后,窗体上显示是什么? -10 23. 阅读程序 Private Sub Command1_Click() Dim x, a, b, c As Integer Dim b1, b2 As Boolean x = 10: a = 5: b = 3: b1 = 0: b2 = -1 If a &lt; b Then If b &lt;&gt; 3 Then &nbsp;If Not b1 Then &nbsp; x = -10 &nbsp; Else &nbsp; &nbsp;If b2 Then x = -30 &nbsp; &nbsp; x = -50 &nbsp; &nbsp; End If &nbsp; &nbsp;End If End If Print x End Sub 单击命令按钮后,窗体上显示是什么? 10 24. 阅读程序 Private Sub Command1_Click() Dim s As String Dim n As Integer s = Left(InputBox(&quot;请输入字符串&quot;), 1) If s &gt;= &quot;c&quot; Then Print Asc(s) + 1 Else &nbsp;Print Asc(s) - 1 &nbsp;End If End Sub 单击命令按钮输入abcd后,窗体上显示是什么?96 25. 阅读程序 Private Sub Command1_Click() Dim s As String Dim n As Integer s = Right(InputBox(&quot;请输入字符串&quot;), 1) If s &gt;= &quot;c&quot; Then Print Asc(s) + 1 Else Print Asc(s) - 1 End If End Sub 单击命令按钮输入abcd后,窗体上显示是什么?101 26. 阅读程序 Private Sub Command1_Click() Dim m, n As Integer m = InputBox(&quot;请输入m的值&quot;) If m / 2 = Int(m / 2) Then n = m Else n = 1 End If Print n End Sub 单击命令按钮输入6后,窗体上显示是什么?6 27. 阅读程序 Private Sub Command1_Click() Dim m, n As Integer m = InputBox(&quot;请输入m的值&quot;) If m / 2 = Int(m / 2) Then n = m Else n = 1 End If Print n End Sub 单击命令按钮输入5后,窗体上显示是什么?1 28. 执行下面的语句后显示的结果是 Private Sub Command1_Click() Dim m, n As Integer m = InputBox(&quot;请输入m的值&quot;) If m / 2 = Int(m / 2) Then m = n + 5 Else m = Sqr(m) End If If n Then Print n Else Print n - 1 End Sub 单击命令按钮输入5后,窗体上显示是什么?-1 29. 阅读程序 Private Sub Command1_Click() Dim y As Integer y = 10 Select Case y Case 1, 3, Is &gt; 6 &nbsp;Print &quot;ok&quot; Case Else &nbsp;Print &quot;stop&quot; End Select End Sub 单击命令按钮后,窗体上显示是什么?ok 30. 阅读程序 Private Sub Command1_Click() Dim x, i As Integer i = InputBox(&quot;&quot;) If i = 1 Then x = i &nbsp; &nbsp; &nbsp;If i &lt;= 4 Then &nbsp; &nbsp; &nbsp; &nbsp;x = x + 1 Else &nbsp; &nbsp; &nbsp; &nbsp;x = x + 2 &nbsp; &nbsp; End If Print x End Sub 单击命令按钮输入5后,窗体上显示是什么?2 31. 阅读程序 Private Sub Command1_Click() Dim x, i As Integer i = InputBox(&quot;&quot;) If i = 1 Then x = i &nbsp; &nbsp; &nbsp;If i &lt;= 4 Then &nbsp; &nbsp; &nbsp; &nbsp;x = x + 1 Else &nbsp; &nbsp; &nbsp; &nbsp;x = x + 2 &nbsp; &nbsp; End If Print x End Sub 单击命令按钮输入1后,窗体上显示是什么?2 32. 阅读程序 Private Sub Command1_Click() Dim x, i As Integer i = InputBox(&quot;&quot;) If i = 1 Then x = i &nbsp; &nbsp; &nbsp;If i &lt;= 2=&quot;&quot; 3=&quot;&quot; 4=&quot;&quot; then=&quot;&quot; x=&quot;&quot; i=&quot;&quot; else=&quot;&quot; end=&quot;&quot; if=&quot;&quot; print=&quot;&quot; sub=&quot;&quot; 33.=&quot;&quot; private=&quot;&quot; dim=&quot;&quot; y=&quot;x&quot; as=&quot;&quot; integer=&quot;&quot; select=&quot;&quot; case=&quot;&quot; is=&quot;&quot;&gt;= 10, Is &lt;= 3=&quot;&quot; 9=&quot;&quot; 10=&quot;&quot; -10=&quot;&quot; y=&quot;x&quot; case=&quot;&quot; to=&quot;&quot; end=&quot;&quot; select=&quot;&quot; print=&quot;&quot; sub=&quot;&quot; 34.=&quot;&quot; private=&quot;&quot; dim=&quot;&quot; as=&quot;&quot; integer=&quot;&quot; x=&quot;&quot; is=&quot;&quot;&gt;= 10, Is &lt;= 10=&quot;&quot; 20=&quot;&quot; -10=&quot;&quot; y=&quot;x&quot; case=&quot;&quot; to=&quot;&quot; end=&quot;&quot; select=&quot;&quot; print=&quot;&quot; sub=&quot;&quot; 35.=&quot;&quot; private=&quot;&quot; dim=&quot;&quot; as=&quot;&quot; integer=&quot;&quot; x=&quot;&quot; is=&quot;&quot;&gt;= 10 y = x Case -10 To 10 y = -x End Select Print y End Sub 单击命令按钮输入20后,窗体上显示是什么?400 36. 阅读程序 Private Sub Command1_Click() Dim x, y As Integer x = InputBox(&quot;&quot;) Select Case sqr(x) Case 1, 3,10,20 &nbsp;y = x * x Case Is &gt;= 10 y = x Case -10 To 10 y = -x End Select Print y End Sub 单击命令按钮输入9后,窗体上显示是什么?81 37. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As Integer, b As Integer a = Int(Rnd()*10 + 1) Select Case a Case 0 &nbsp; Print &quot;****&quot; Case is&lt;10 print=&quot;&quot; case=&quot;&quot; else=&quot;&quot; end=&quot;&quot; select=&quot;&quot; sub=&quot;&quot; 38.=&quot;&quot; private=&quot;&quot; dim=&quot;&quot; a=&quot;&quot; as=&quot;&quot; b=&quot;InputBox(&quot;输入第2个数据:&quot;)&quot; c=&quot;&quot; string=&quot;&quot; if=&quot;&quot;&gt;b Then c = abs(a)+sqr(b) Else &nbsp;c = 3 ^ 3 \ 3 * 3 End If Print c End Sub 设输入的数据分别为“5”和“6”时,单击后,窗体上显示是什么? 3 39. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer a = InputBox(&quot;输入第1个数据:&quot;) b = InputBox(&quot;输入第2个数据:&quot;) If a &gt; b Then If a then c = abs(a)+sqr(b) end if Else &nbsp;c = a*b mod 3 End If Print c End Sub 设输入的数据分别为“0”和“5”时,单击后,窗体上显示是什么? 0 40. 下列程序段的执行结果为 Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer a = InputBox(&quot;输入第1个数据:&quot;) b = InputBox(&quot;输入第2个数据:&quot;) If a &gt; b Then If Not a Then c = Abs(a) + Sqr(b) Else c = Abs(a) - Sqr(b) End If Else &nbsp;If Not a Then &nbsp; c = a * b Mod 3 &nbsp; Else &nbsp; c = a ^ 3 + 4 End If End If Print c End Sub 设输入的数据分别为“9”和“3”时,单击后,窗体上显示是什么? 11 1. 在窗体上画一个命令按钮,然后编写如下事件过程: Private Sub Command1_Click() x=0 Do Until x=-1 a = InputBox(“请输入A的值”) a = Val(a) b = InputBox(“请输入B的值”) b = Val(b) x = InputBox(“请输入x的值”) x = Val(x) a = a+b+x Loop Print a End Sub 程序运行后,单击命令按钮,依次在输入对话框中输入5、4、3、2、1、-1,则输出结果为 。2 2. 阅读下面的程序段: For &nbsp;i=1 To 3 For &nbsp;j=1 To i For k=j To 3 a=a+1 Next k Next j Next i Print a 执行上面的三重循环后,a 的值为 。 14 3. 在窗体上画一个文本框(其中Name属性为Text1),然后编写如下事件过程: Private Sub Form_Load() Dim sum as integer text1.text=&quot;&quot; For &nbsp;i=1 To 10 Sum=Sum+i Next i Text1.Text=Sum End Sub 上述程序的运行结果是 。55 4. 在窗体上画两个文本框(其Name 属性分别为Text1和Text2)和一个命令按钮(其Name属性为Command1),然后编写如下事件过程: Private Sub Command1_Click() x=0 Do While x&lt;50 x=(x+2)*(x+3) n=n+1 Loop Print x,n End Sub 程序运行后,单击命令按钮,显示为 &nbsp; &nbsp;72 &nbsp;2 5. 阅读下面的程序段: x=2 For i=1 To 5 x=x+i Print &nbsp;x, Next 程序运行后,显示 &nbsp; 3 5 8 12 17 6. 阅读下面的程序段: x=0 For i=1 to 2 &nbsp;For j=1 to 3 x=x+j Next j Next i Print x 程序运行后,显示 &nbsp; &nbsp;12 7. 阅读下面的程序段: Dim i As Integer, x As Integer &nbsp; For i = 1 To &nbsp;6 &nbsp; &nbsp; &nbsp;If i = 1 Then x = i &nbsp; &nbsp; &nbsp;If i &lt;= 1=&quot;&quot; 2=&quot;&quot; 4=&quot;&quot; 9=&quot;&quot; 10=&quot;&quot; 11=&quot;&quot; then=&quot;&quot; x=&quot;1&quot; else=&quot;&quot; end=&quot;&quot; if=&quot;&quot; next=&quot;&quot; i=&quot;&quot; print=&quot;&quot; 8.=&quot;&quot; private=&quot;&quot; sub=&quot;&quot; c=&quot;ABCD&quot; for=&quot;&quot; n=&quot;1&quot; to=&quot;&quot; d=&quot;&quot; cd=&quot;&quot; bcd=&quot;&quot; abcd=&quot;&quot; 9.=&quot;&quot; step=&quot;&quot; 10.=&quot;&quot; y=&quot;&quot; do=&quot;&quot; until=&quot;&quot;&gt;4 X=X*Y Y=Y+1 Loop Print X 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4 11. 阅读下面的程序段: x=0 For i=1 to 2 For j=1 to 3 x=x+j Next j Next i Print x 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 12 12. 阅读下面的程序段: Private Sub Form_Click() Dim n1 as integer,n2 as integer,n3 as integer n1=1:n2=1 Do &nbsp;N3=n1+n2 &nbsp;Print n3, N1=n2:n2=n3 Loop &nbsp;Until n3&gt;=5 &nbsp;End &nbsp;Sub 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2 &nbsp;3 &nbsp;5 13. 阅读下面的程序段: &nbsp; &nbsp;X=1 Y=4 Do Until Y&gt;4 X=X*Y^2 Y=Y+1 Loop Print X 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;16 14. 阅读下面的程序段: Private Sub Command1_Click( ) For i = 1 T0 3 For j = 0 TO i S = S + 1 Next j,i Print s End Sub 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;9 15. 阅读下面的程序段: Private Sub Command1_Click( ) x =1:y=1 For i=1 T0 3 x = x + y : y = y + x Next i print x,y End Sub 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;13 &nbsp;21 16. 阅读下面的程序段: For a =1 TO 5 For b = 1 TO 10 a=a +1 b=b+1 Next b Next a Print b End Sub 程序运行后,显示 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 11 17. 在窗体上画两个文本框(其Name 属性分别为Text1和Text2)和一个命令按钮(其Name属性为Command1),然后编写如下事件过程: Private Sub Command1_Click() x=0 Do While x&lt;50 x=x^2+(x mod 2)+1 n=n+5 Loop Text1.Text=Str(n) Text2.Text=Str(x) End Sub 程序运行后,单击命令按钮,在两个文本框中显示的值分别为 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 20 &nbsp; 123 18. 下面语句运行后的输出结果是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;16 Private Sub Command1_Click( ) x=2 do While x &lt; 10 x =x + l x = x * x loop Print x End Sub 19. 在窗体上画两个名称分别为Text1、Texte2的文本框和一个名称为Command1的命令按钮,然后编写如下事件过程: Private Sub Command1_Click() Dim x As Integer,n As Integer x=1 n=0 Do While x&lt;20 x=x*3 n=n+1 Loop Text1.Text=Str(x) Text2.Text=Str(n) End Sub 程序运行后,单击命令按钮,在两个文本框中显示的值分别是 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 27 &nbsp;3 20. 下列程序段的输出结果为________。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0 Private Sub Command1_Click( ) Dim S as integer, N as integer i=1:sum=0 Do &nbsp;While i&lt;=100 &nbsp;sum=sum+i &nbsp;i=i+1 Loop Print Str(S) End &nbsp;Sub 21. 下列程序段的输出结果为________。 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;37 &nbsp;74 &nbsp;111 &nbsp;148 &nbsp;185 Private Sub Command1_Click( )        a=”” &nbsp; &nbsp; &nbsp; For n=1 To 200 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If n Mod 37=0 Then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a=a &amp;Str(n)&amp;” ” &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End If &nbsp; &nbsp; &nbsp; Next &nbsp; &nbsp; &nbsp; Text1.Text=a End Sub 22. 、设有如下程序段,运行后,x的值是:17 x=2 For i=1 To 5 x=x+i Next 23. 执行如下程序段,输出结果为:0 a=0 For i=1 to 5 a=a*i Next i Print a 24. 执行如下程序段,输出结果为:12 x=0 For i=1 to 2 &nbsp;For j=1 to 3 x=x+j Next j Next i Print x 25. 命令按钮的Name属性为Command1,编写如下代码,则在程序运行时,单击该命令按钮,输出结果为:1 2 6 Private Sub Command1_Click() For i=1 to 3 x=1 For j=1 to i x=x*j Next j Print j; Next i End Sub 26. 程序 p = InputBox(&quot;请输入字符串:&quot;) For i = Len(p) To 2 Step -2 Print Left(p, i) Next i End Sub 如果输入:ABCDEFG ,则结果: ABCDEFG ABCDE ABC 27. 程序 p = InputBox(&quot;请输入字符串:&quot;) For i = Len(p) To 2 Step -2 Print right(p, i) Next i End Sub 如果输入:ABCDEFG ,则结果: ABCDEFG CDEFG EFG 28. 程序3: Private Sub Form_Click() &nbsp; &nbsp; Dim i As Integer ,j As Integer &nbsp; &nbsp; Dim star As String &nbsp; &nbsp; star=&quot;#&quot; &nbsp; &nbsp; For i=1 To 6 &nbsp; &nbsp; &nbsp; For j=i To 6 &nbsp; &nbsp; &nbsp; &nbsp; Form1.Print star; &nbsp; &nbsp; &nbsp; Next j &nbsp; &nbsp; &nbsp; Form1.Print &nbsp; &nbsp; &nbsp;Next i End Sub 写出程序运行后,单击窗体后,Form1上输出</p><!--=--><!--10--><!--=--><!--=--><!--=--><!--=--><!--=--><!--10-->
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 考试专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服