第一范文网 - 专业文章范例文档资料分享平台

高职单招VB程序练习

来源:用户分享 时间:2025/8/18 9:26:23 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

1.private Sub Command1_Click ()

Dim a As Integer , b As Integer a=60 : b=a

print “a=” ; a . ” b=”;b End Sub

上面程序运行后,单击Command1mingling按钮.输出结果是______. 2.Private Sub Command1_Click ()

Dim x As Integer ,y As Integer, z As Integer x=1: y=2 If x> 1 Then z=1

ElseIf x<>y Then z=2 Else z=3 End If

Print ”z=”;z End Sub

上面程序运行后,单击Command 1命令按钮,输出结果是______. 3.ivate Sub Command1_Click() Dim s As String, n As Integer

S=”1a2b3c” N=Val(s)+23 Print n End Sub

上面程序运行后,单击Command1 命令按钮,输出结果是______. 4.vate Sub Command1_Click() Dim i As Integer, sum As Integer Sum=0

For u = 1 to 10 step 2 Sum =sum +1 Next i

Print sum End Sub

上面程序运行后,单击Command1 命令按钮,输出结果是______. 5.ivate Sub Command1_Click() Dim n As Integer n=1

While n<=5 n=n+1 Wend

Print “n=” ; n End Sub

上面程序运行后,单击Command1命令按钮,输出结果是_______。

6.Private Sub Command1_click() Dim i As Integer , s As String s=””

For i= 1 To 6

If i Mod 3 = 0 Then s=s& “$” Else

s=s& “*” End If Next i

Print s End Sub

上面程序运行后,单击Command1命令按钮,输出结果是_______。 7.Private Sub Command1_click()

Dim x As Variant,max As Integer,n As Integer x=Array(7,2,4,,6,8,9) max=x(0) n=1 Do

If max

Loop While n<6 Print “max=”;max End Sub

上面程序运行后,单击Command1命令按钮,输出结果是_______。 8.Private Sub Command1_click() x=InputBox(“Input x:”)

x=x+”1” Print x End Sub

上面程序运行后,单击Command1命令按钮,在Inputbox对话框中输入5432.并确认后。输出的结果是_______。

9.Private Sub Function testfun(ByVal n As Integer) Print testfun(5)

End Sub

Private Function testfun(ByVal As Integer) Dim i As Integer,t As Long t=1

For i = 1 To n Next i

testfun=t End Function

上面程序运行后,单击Command1命令按钮,输出结果是_______。

10.Private Sub Command1_click() Dim a As Integer,b As Integer Dim a As Integer,b As Integer A=30 :b=20 Call testsub(a,b) Print a , b End Sub

Private Sub testsub(x As Ineger , y As Integer) x=x-y : y=x+y

End Sub

上面程序运行后,单击Command1命令按钮,输出结果是_______。

五、程序填空题(请正确填充下列的VB程序,使其完成所需求的功能。每空2分,共28分)

1.求和sum—1*2+2*3+*…+99*100 Private Sub Command1_Click() Dim i As Integer , sum As Long Sum=0

For i=1 To _________ Sum=sum+_______ Next i

Print “sum” ; sum

End Sub

2.输入职工的年终考核得分,然后将考核得分转换为考核登记,转换规则如下:90分以上为”优”。60~89分为”合格”,其他为”不合格”。 Private Sub Command1_click()

Dim k As Integer

k=inputbox(“请输入职工的年终考核得分 : ”) Select Case k Case Is>=90 Print “优” Casse ______ Print”合格” ________

Print”不合格”

End Select End Sub

3.用二重循环输出如下图案(第一行的” * ”列位置设置为20) * * * * * * * * * * * * * * * * * * * * * Private Sub Command1_click()

Dim I As Integer , j As Integer For i1 To 6

Print______; For i = 1 To i Print “ * “; Next j ______

Next i End Sub

4.窗体Form1上有一个命令按扭Ccommand1,单击该命令按钮。隐藏Form1窗体,显示Form2窗体。

Private Sub Command1_click() ______;

Form2.______

End Sub

5.窗体上有一个文本框Text1,一个标签Label1和一个命令按钮Command1,在文本框中输入一个圆的半径值后,单击命令按钮,在标签上显示圆的面积。 Private Sub Command1_click() Dim r As Single , area As Single

R=_________________________________ Area=3.14*r*r

_________________________________=Str(area) End Sub

6.给二维数组A(4.4)赋初值,取值如下: 1 0 0 0 0 2 2 0 0 0 3 3 3 0 0 4 4 4 4 0 5 5 5 5 5

Private Sub Command1_click()

Dim A(4 , 4) As Integer , I As Integer , j As Integer For i = 0 To 4

For j = 1 To 4 If ______ Then A(i , j)=0 Else

A(i , j)=______ End If Next j Next i

End Sub

7.用冒泡法对随即生成的20个输按从大到小排序。 Private Sub Command1_click()

Dim x(1 To 20) As Single

Dim i As Integer , j As Integer , temp As Single For i = 1 To 20

x(i)=Rnd*101 Next i

For i = 1 To 20 Step -1 For j=1 To ______

If______ Then

temp=x(j) : x(j)=x(j+1) : x(j+1)=temp End If Next j Next i

For j = 1 To 20 Print x(j) Next j End Sub

搜索更多关于: 高职单招VB程序练习 的文档
高职单招VB程序练习.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c88lws5r2ss0daes3z438_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top