《vb题型参考.doc》由会员分享,可在线阅读,更多相关《vb题型参考.doc(6页珍藏版)》请在三一办公上搜索。
1、一 选择题(20)1. 下列变量名中,合法的变量名是(a ) AC24 B.A B C.A:B D.1+2 2. 请问将数据输出显示的时候,以下哪种方式不适用?dA. 标签label B.文本框textbox C.msgbox函数 D.inputbox函数3. 以下哪个函数计算结果不是6?dA.Len(VB.NET) B.Int(6.5) C.15 mod 9 D.15 / 9 4. 若要使命令按钮不可用,则可设置其(c)属性为False来实现。 、Value、Cancel、Enabled、Default 5. 如下数组声明语句中,正确的是a。ADim a(3, 4) As IntegerBD
2、im a3, 4As IntegeCDim a(3, 4) As IntegeDDim a(34) As Intege6. 下列控件中,没有Text属性的是 d 。 A框架B列表框 C单选框D定时器7. 在设计状态,列表框中的选项可以通过c属性设置AList BItems.Count CItems DText8. 要调整某控件的宽度,应修改 c 属性。ATop BLeft CWidth DHeight9. 设置计时器时间间隔的属性是c。AEnabled BName CInterval DModifiers10. 已知a=12,20,复合赋值语句“a*=b+10”执行后,a变量中的值为 b 。A
3、50 B250 C30 D360二、综合题(30)1.数学表达式a=x=a and x=b2. 过程和函数的区别有哪些? 子过程与函数特点(异同): 子过程Sub,不直接返回值或者传递多个值; 函数Function直接返回一个值。 都是完成特定功能的程序代码段。3. 在vb中如何表示?4. 计算下列循环语句的次数For i=-1 to 18 strp 35. for i=1 to 10 a: k=k+1 for j=1 to 3 b: m=m+knext jnext i请问a执行了几次,b执行了几次?10,30三、读程题(3*54=12)1.请写出程序运行后的结果Private Sub But
4、ton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i%, s$ Dim s1 As String = For i = 1 To 5 s = Mid(s1, 1, 11 - 2 * i) Label1.Text &= Space(2 * i) & s & vbCrLf Next For i = 1 To 4 s = Mid(s1, 1, 2 * i + 1) Label1.Text &= Space(10 - 2 * i) & s & vbCrLf Ne
5、xtEnd Sub2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a(5, 5) As Integer Dim i%, j% For i = 1 To 3 For j = 1 To 4 a(i, j) = i * j Label1.Text &= a(i, j) & Next Label1.Text &= vbCrLf Next End Sub当单击命令按钮后,标签中显示内容为:3.用户点击button1后出现什么
6、结果?Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer For i = 5 To 1 Step -0.8 TextBox1.Text &= Int(i) Next iEnd Sub543214.用户点击button1后出现什么结果?Public Sub Proc(ByRef a%() Static i% Do a(i) = a(i) + a(i + 1) i = i + 1 Loop While
7、i 2 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i%, x%(10) For i = 0 To 4 : x(i) = i + 1 : Next i For i = 1 To 2 : Call Proc(x) : Next i For i = 0 To 4 : Label1.Text &= x(i) & : Next i End Sub35745四、编程题(38)1.税务部门征收所得税,规定如下:收
8、入在200元以内,免征;收入在200400元内,超过200元的部分纳税3%;收入在4004000元内,纳税4%;收入在4000元或超过时,税金为5%。 由输入对话框输入的收入金额,编程计算并用输出对话框输出总的纳税金额。2. 要求输入加班总时间,加班时间控制在8小时之内的整数,如果加班时间小于2小时,按照30/小时计算;如果加班时间大于2小时,按照20/小时计算,请设计界面并计算用户的加班收入。 3. 随机产生20个10,100之间的整数,输出这20个数,并求这批数的最大值及最大值位置。4.查找用户输入的一行文字中是否含有“VB”,如果有,输出“VB”出现的次数。1.Private Sub B
9、utton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myincome As Single Dim mytax As Single myincome = Val(TextBox1.Text) If myincome = 200 Then mytax = 0 ElseIf myincome = 400 Then mytax = (myincome - 200) * 0.03 ElseIf myincome = 4000 Then mytax = (myi
10、ncome - 200) * 0.04 Else mytax = (myincome - 200) *0.05 End IfTextBox2.Text = mytax End SubEnd Class3. 数组一Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim a%(19) Dim i% Dim max% Randomize() For i = 0 To 19 a(i) = Int(Rnd()
11、* 91) + 10 TextBox1.Text &= a(i) & Space(2) Next TextBox1.Text &= vbNewLine max = a(0) For i = 1 To 9 If max 0) Count = Count + 1 st = Mid(st, i + 1) i = InStr(st, vb ) Loop End Function Sub Procthe(ByVal st$, ByRef Count%) Dim i% Count = 0 i = InStr(st, vb ) Do While (i 0) Count = Count + 1 st = Mi
12、d(st, i + 1) i = InStr(st, vb ) Loop End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox2.Text = Count(TextBox1.Text) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim num% Call Procthe(TextBox1.Text, num) TextBox3.Text = num End SubEnd Class