内容发布更新时间 : 2024/12/27 16:47:01星期一 下面是文章的全部内容请认真阅读。
VB程序阅读题与程序填空题综合练习
Private Sub Form_Click( )
Dim i As Integer, j As Integer Dim k As Integer For i = 0 To 10 Step 3
For j = 1 To 10
If j > = 5 Then i = i +4: Exit For j = j + 1 k = k + 1
1、阅读下面程序,当单击窗体之后,窗体上输出的是 。
k=0
Next
If i > 8 Then Exit For
Next Print k
End Sub
是 和 ;若将程序中A语句与B语句的位置互换,再次执行程序,
2、阅读下面的事件过程。单击窗体后,在文本框Text1和Text2中显示的内容分别 单击窗体后在Text1和Text2中显示的内容分别是 和 。 Private Sub Form_Click( )
Dim x As Integer, y As Integer x = 1 : y = 0 Do While x < 3
y = y + x 'A语句
'B语句
x = x + 1 Loop Text1.Text = x Text2.Text = y
End Sub
Dim b As Integer, k As Integer b = 1 For k =1 To 5 b = b * k
If b > = 15 Then Exit For Else
3、下面程序段中,k循环共执行 次,在窗体上显示的结果是 。
k = k + 1
End If Next k
Print k, b
体上,在划线处填上缺少的内容。
4、以下是按钮cmdl的Click事件过程,求1~100之间的所有质数。质数的个数显示在窗
Private Sub cmdl_Click( )
Dim intNum As Integer, int1 As Integer, int2 As Integer intNum = 0
For int1 =
For int2 = 2 To int1 \\2
If (int1 Mod int2) = 0 Then
intNum=1 End If
Next If
sNum = sNum + 1 End If
Next
End Sub
5、若命令按钮的名称为CmdExit,程序要求单击以上命令按钮时,程序停止运行。请在画线处中填入适当的内容。 Private Sub CmdExit_ ( )
End Sub
6、下面的事件过程判断文本框txt1中输入的数所在区间,并在文本框txt2中输出判断结果。在画线处填入正确的内容。
Private Sub Comandl_Click( )
Dim int1 As Integer int1 =val (txt1.Text) Select Case int1
Case txt2.Text = \值为0\Case
txt2.Text = \值在1和10之间(包括1和10)\txt2.Text = \值大于10\Case
Case Else
txt2.Text = \值小于0\
End Select
End Sub
3.运行结果:
For X = 5 To 1 Step –1 For Y = 1 To 6 - X Print Tab(Y + 5); \ Next Y Print
Next X 4.运行结果:
S = 0: T = 0: U = 0 For X = 1 To 3 For Y = 1 To X For Z = Y To 3 S = S + 1 Next Z T = T + 1
Next Y Next X Print S; T; U 5.运行结果:
Private Sub Command1_Click()
Dim b As Integer a = 3.6 b = 3.6 Text1.Text = a Text2.Text = b End Sub
四、读程序题,写出程序运行结果。 1.运行结果:
Private Sub Form_Click() For I = 1 To 9
For j = 1 To 30 - 3 * I Print \ Next j For k = 1 To I Print k; Next k
For k = I - 1 To 1 Step -1 Print k; Next k Print Next I End Sub 2.运行结果:
Static S As Integer Dim i As Integer S = 1
For i = 1 To 5 S = S * i Next i Print S
End Sub
2.以下程序判断从文本框Text1中输入的数据,如果该数据满足条件:除以3余2,除以5余3,除以7余4,则输出;否则将焦点定位在文本框Text1中,选中其中的文本。 Private Sub Command_Click() X = Val(Text1.Text) If (1) Then Private Sub Command1_Click() U = U + 1
Print X
Else
(2) (3)
(4) End If
End Sub 五、编程题 文本框1(text1)命令按钮1command1文本框2(text2)文本框3(text3)命令按钮3文本框4(text4)command3命令按钮2command21.设计一个计算程序。该程序用户界面如图所示,由四个文本框:文本框1(text1)、文本框2(text2)、文本框3(text3)、文本框4(text4),和三个按钮:命令按钮1(command1)、命令按钮2(command2)、命令按钮3(command4)组成.程序运行后,用户按清除按钮,则清除文本框中显示的内容,按计算按钮,则计算三科平均成绩。单击退出按钮则退出。 Private Sub Command1_Click() Text1.Text = Text2. [2] End Sub
Private Sub Command2_Click() If Text1. [4]= \ Else
Text4.Text = (
Private Sub Command3_Click()
[8 ]
[6 ] + Val(Text2.Text)
[6] [7]
+ Val(Text3.Text)) / [7 ] End Sub
[5] Or Text3.Text = \
[4] MsgBox \成绩输入不全!\ [5] [3]
[1] [2] [3] = \
.Text = \
[8] Unload [9] [10] Sub
[9] [10]
3.设计一个欢迎程序。该程序用户界面如图所示。要求程序运行后,用户选中粗体复选框时 “欢迎您!”几个字的字体变成粗体,用户选中斜体复选框时 “欢迎您!”几个字的字体变成斜体。若取消选中,则恢复原字体。按结束,则退出。
4.任给3个数,求其中间数,写出程序代码。
三、阅读程序题
1.阅读下列程序并写出程序运行结果
Private Sub Form_Click()
Dim s As Long, f As Long, n As Integer, i As Integer n = 3
For i = 1 To n f = f + i s = s + f Next
Print \End Sub
写出程序运行时单击窗体后,窗体Form1上的输出结果。 运行结果:
2.阅读下列程序并写出程序运行结果
Private Sub Command1_Click() x = 0
Do While x < 100
x = (x + 2) * (x + 4) n = n + 1 Loop
Text1.Text = Str(n) Text2.Text = Str(x)
Text3.Text = Val(Text1.Text) + Val(Text2.Text) End Sub
文件框Text3的结果是: