Vb知识点总结1

总结

常用标准控件

选择题1

1.要设置计时器控件的定时时间,需设置的属性是

A.Interval B.Enabled C.Value D.Text

2.控制名称都是系统的默认控件名,下列语句错误的是。

A.Command1.Caption=List1.Text

B.Label1.Caption=List1.List(1)

C.List1.List(2)=List1.Text+Str(List1.ListIndex)

D.Text1.Text=List1.Name+Text1.Caption

3.窗体上有一个命令按钮Command1、一个文本框Text1和一个列表框List1。文本框用来输入要添加到列表框中的项目内容。程序运行后,单击命令按钮,会将文本框中的内容放入列表框中。程序如下:

Private Sub Commandl_Click()

Text1.Text=" "

Text1.SetFocus

End Sub

程序的空白行应填写语句 。

A.List1.Text=Text1.Text B.Listl.List=Textl.Text

C.Listl.AddItem=Textl.Text D.Listl.AddItem Textl.Text

4.以下过程是标签Label1的

Prviate Sub Label1_Click( )

End Sub

A.单击 B.双击 C.拖拽 D.移动

5.标签的边框由 属性的设置来决定。

A.BackColor B.BackStyle C.BorderStyle D.AutoSize

6.单选按钮的当前状态可通过

A.Value B.Checked C.Selected D.Caption

7.下列控件中可设置滚动条是

A.检查框(复选框) B.框架 C.文本框 D.标签框

8.标签所显示的内容,由属性值决定。

A. Text B. Name C. Caption D. Alignment

9.标签中内容的对齐方式,由

A.Text B.Name C.Caption D.Alignment

10.若要设置文本框最大可接收的字符数,可通设置 属性值来实现。

A.Multiline B.Length C.Min D.MaxLength

11.在VB 窗体要设计两组单选按钮,应用 控件对其分组。

A.Picture B.Image C.Label D.Frame

12.若要求向文本框输入密码时,只在文本框中显示&号,则应当在此文本框的属性窗口中设置。

A. Text属性值为 & B. Caption属性值为 &

C. PasswordChar属性值为空 D. PasswordChar属性值为 &

13.定时器的定时间隔单位是 。

A. 秒 B. 微秒 C. 毫秒 D. 分

14.若要设置定时器的定时间隔设为5秒,应将Interval属性值设为

A. 5 B. 50 C. 500 D. 5000

15.若要使定时器起作用,应将其 属性设置值设为True。

A.Interval B.Value C.Text D.Enabled

16.若要使命令按钮失效,可设置属性为False来实现。

A.Value B.Enabled C.Visible D.Cancel

17.若要将命令按钮设置为默认按钮,可设置属性为True来实现。

A.Cancel B.Value C.Enabled D.Default

18.若要使不可见命令按钮显示出来,可通过设置True来实现。

A.Visible B.Enabled C.Default D.Value

19.在运行时,若要能调用某命令按钮的Click事件过程,应将该按钮的 属性设置为 True。

A.Visible B.Enabled C.Default D.Value

20.若要使命令按钮获得控制焦点,可使用 方法来设置。

A.Refresh B.SetFocus C.GetFocus D.LostFocus

21.要将命令按钮上的文字设置为“粗体”可通过设置True来实现。

A.FontItalic B.FontBold C.FontUnderline D.FontSize

22.要将命令按钮上的文字设置为“斜体”可通过设置 属性值为True来实现。

A.FontItalic B.FontBold C.FontUnderline D.FontSize

23.要将命令按钮上的字体设为“隶书”,可设置的属性为“隶书”。

A.FontBold B.BackItalic C.FontName D.FontSize

24.若要向列表框新增列表项,可使用 方法来实现。

A.Add B.RemoveItem C.Clear D.AddItem

25.若要获得当前列表项的数目,可通过访问 属性来实现。

A.Columns B.Text C.ListIndex D.ListCount

26.若要清除列表框中列表项,可使用

A.Add B.RemoveItem C.Clear D.AddItem

27.用户在组合框中所输入的数据,可通过访问组合框对象的属性来获得。

A.Text B.List C.List index D.ListCount

28.用鼠标选择列表框中的项目,将触发其事件。

A.Change B.Click C.Select D.ItemCheck

29.组合框的风格可通过属性来设置。

A.BackStyle B.BorderStyle C.Style D.Sorted

30.要获得垂直滚动条Vscrollbar控件所能表示的最大值,可通过调用该控件的 属性来实现。

A.Value B.Max C.Min D.LargeChange

31.若要获得滚动条的当前值,可通过访问属性来实现。

A.Text B.Value C.Max D.Min

32.当滚动条中的滑块位置变化时,将触发其事件。

A.LostFocus B.SetFocus C.Change D.GetFocus

33.当拖动滚动条时,将触发其事件。

A.LostFocus B.SetFocus C.Scroll D.GetFocus

34.假定Picture1和Form1分别为图片框和窗体的名称,以下语句可清除图片框中的文本信息。

A.Picture1.cls B.Picture1.clear C.Form1.cls D.Form1.clear

35.确定一个窗体或控件的大小的属性是 。

A.Width或Height B.Width和Height

C.Top或Left D.Top和Left

36.确定一个控件在窗体上的位置的属性是。

A.Width或Height B.Width和Height

C.Top或Left D.Top和Left

37.假定Picture1,Form1,Text1,Label1分别为图片框、窗体、文本框、标签的名称,程序代码如下,单击图片框时,清除下列哪个对象的内容 。

Private Sub Picture1_Click()

Cls

End Sub

A.Picture1 B.Text1 C.Form1 D.Label1

38.若要将图片"D:\PIC\CAR.JPG"载入到当前的图片框(PictureBox)中,应用

A.LoadFile B.LoadPicture C.LoadPic D.LoadJPG

39.在图片框(PictureBox)中显示的图形,由对象的属性决定。

A. Picture B. Image C. Icon D. LoadPic

40.控件数组是通过

A.名称 B.Count属性 C.Index属性 D.控件标题

数组

选择题

1.有一数组定义语句:Dim M(-2 to 1) As string,则数组M中包含的元素个数为。

A.4 B.3 C.2 D.1

2.语句:Dim student(10,5) As Long定义的数组元素的类型为 。

A.整型 B.字符型 C.逻辑型 D.长整型

3.默认情况下,语句:Dim student(2,3,4) 定义的数组有 个元素。

A.60 B.9 C.24 D.12

4.有以下数组声明语句:Option Base 1: Dim A(3,2 to 4),则数组A有

A.3 B.4 C.12 D.9

5.下列程序

Option Base 1

Private Sub Form_Click()

Dim a(100)

For i=1 To 10

j=i*i

a(j)=j

Next i

Print a(25);

End Sub

程序运行时输出的结果是 。

A.16 B.25 C.36 D.出错信息

6.下列程序

Option Base 1

Private Sub Form_Click()

Dim a

a=Array(19,17,15,13,11,9,7,5,3,11)

For i=1 To 10

If a(i)/3=a(i)\3 Or a(i)/5=a(i)\5 Then

Sum=Sum+a(i)

End If

Next i

Print "Sum="; Sum

End Sub

运行时输出Sum的值是 。

A.27 B.15 C.32 D.20

7.在窗体上画一个命令按钮(其Name属性为Command1),然后编写如下代码:

Option Base 1

Private Sub Command1_Click()

Dim a(4,4)

For i=1 To 4

For j=1 To 4

a(i,j)=(i-1)*3+j

Next j

Next i

For i=3 To 4

For j=3 To 4

Print a(j,i)

Next j

Print

Next i

End Sub

程序运行后,单击命令按钮,其输出结果为 。

A.6 9 7 10 B.7 10 C.8 11 D.9 12 10 13

8.下面程序的功能是:程序从键盘读取40个数保存到数组A中,将一维数组A中各元素的值移到后一个元素中,而最末一个元素的值移到第一个元素中去。然后,按每行4个数的格式输出。请在画线处填入适当内容,将程序补充完整:

Option Base 1

Private Sub Command1_Click()

Dim a(40) As Integer

For i=1 To 40

a(i)=Val(InputBox("请输入一个整数"))

Next i

b=a(40)

For i=

a(i+1)=a(i)

Next i

a(1)=b

For i=

Print a(i);

If i [3] 4 = 0 Then Print

Next i

End Sub

【解答】[1]39 To 1 Step [2]1 To 40 [3] Mod

过程

选择题

1.使用过程编写程序主要是为了 。

A.使程序模块化 B.使程序易于阅读

C.提高程序运行速度 D.便于系统的编译

2.下列关于函数说明正确的是

A.定义函数过程时,若没有用As子句说明函数的类型,则函数过程与Sub过程一样,都是无类型过程

B.在函数体中,如果没有给函数名赋值,则该函数过程没有返回值

C.函数名在过程中只能被赋值一次

D.函数过程是通过函数名返回函数值的

3.过程调用语句中,被调用的过程一定是Sub过程的语句是

A.Call Pro1(a1, b1) B.Pro2(a2, b2)

C.Print Pro3(a3, b3) D.x=Pro4(a4, b4)

4.设有子过程Pro1,有一个虚参变量。下列调用语句中,按传址方式传递数据的语句是 。

A.Call Pro1(a) B.Call Prol(12)

C.Call Pro1(a*a) D.Call Prol(12+a)

5.下列程序

Dim b

Private Sub Form1_Click()

a=1:b=1

Print "A=";a;",B=";b

Call mult(a)

Print"A=";a;",B=";b

End Sub

Private Sub mult(x)

x=2*x

b=3*b

End Sub

运行后的输出结果为 。

A.A=1 B=1 B.A=1 B=1 C.A=1 B=1 D.A=1 B=l

6.程序如下:

Private Sub Form_Click()

Dim a As Integer, b As Integer

a=10 : b=20

Call ff(a,b)

Print a,b

End Sub

Private Sub ff(x As Integer, y As Integer)

x = x + y

y = x + y

End Sub

程序运行时,单击窗体后,在窗体上输出的结果是 。

A.10 20 B.20 20 C.30 30 D.30 50

7.已知一窗体中有如下函数过程和一命令按钮Command1,且Command1的Click事件中只有一行命令:Print Max(1,2,3),则单击Command1时,输出结果为

Private Function Max( a,b,c)

m=a

if b>m then m=b

if c>m then m=c

Max=m

End Function

A. 1 B. 2 C. 3 D. 6

8.已知一窗体中有如下函数过程和一命令按钮Command1,且Command1的Click事件中只有一行命令:Print Sum(1,2,3),则单击Command1时,输出结果为。

Private Function Sum( a,b,c)

Sum=a+b+c

End Function

A. 1 B. 2 C. 3 D. 6

9.已知一窗体中有如下函数过程和一命令按钮Command1,则单击Command1时,输出结果为。 Private Function Sum( a,b,c)

a=a+1:b=b+1:c=c+1

Sum=a+b+c

End Function

Private Sub Command1_Click( )

a=1:b=2:c=3

Call Sum(a,b,c)

Print a;b;c

End Sub

A. 1 2 3 B. 2 3 4 C. 3 4 5 D. 4 5 6

10.已知一窗体中有如下函数过程和命令按钮Command1,则单击Command1时,输出结果为 。 Private Function Sum( ByVal a, ByVal b,ByVal c)

a=a+1:b=b+1:c=c+1

Sum=a+b+c

End Function

Private Sub Command1_Click( )

a=1:b=2:c=3

Call Sum(a,b,c)

Print a;b;c

End Sub

A. 1 2 3 B. 2 3 4 C. 1 3 4 D. 1 2 4*A

11.已知一窗体中有如下函数过程和一命令按钮Command1,则单击Command1时,输出结果为 Public Function even(x)

If x Mod 2 = 0 Then

even = 1

else

even = 0

End If

End Function

Private Sub Command1_Click()

n = 20

If even(n) = 1 Then

Print n; "is a even number."

Else

Print n; "is not a even number."

End If

End Sub

A. 20 is a even number. B. 20 is not a even number.

C. n is a even number. D. n is not a even number.

12.已知一窗体中有如下函数过程和一命令按钮Command1,则单击Command1时,输出结果为 。 Public Function Fun(x, y)

Fun = 1

For I = 1 To y

Fun = Fun * x ?x的y次方

Next I

End Function

Private Sub Command1_Click()

Print Fun(3, 4)

End Sub

A. 3 B. 4 C. 81 D. 256

13.已知一窗体中有如下子过程和一命令按钮Command1,则单击Command1时,输出结果为。 Public Sub change(ByVal x, ByVal y)

t = x: x = y: y = t

End Sub

Private Sub Command1_Click()

a = 12: b = 34: Call change(a, b)

Print a; b

End Sub

A. 12 34 B. 34 12 C. 21 43 D. 43 21

14.已知一窗体中有如下子过程和一命令按钮Command1,则单击Command1时,输出结果为 。 Public Sub change(x, y)

x = y

End Sub

Private Sub Command1_Click()

a = 12: b = 34: Call change(a, b)

Print a; b

End Sub

A. 12 34 B. 34 34 C. 34 12 D. 12 12

15.已知一窗体中有如下子过程和一命令按钮Command1,且Command1的Click事件中只有一行命令:Print_Number,则程序运行中第三次单击Command1时,输出结果为

Private Sub Print_Number( )

Dim x

x = x + 10

Print x

End Sub

A. 0 B. 10 C. 20 D. 30

16.已知一窗体中有如下子过程和一命令按钮Command1,且Command1的Click事件中只有一行命令:Print_Number,则程序运行中第三次单击Command1时,输出结果为

Private Sub Print_number( )

Static x

x = x + 10

Print x

End Sub

A. 0 B. 10 C. 20 D. 30

17.以下定义的函数中不是按“传址”方式传递参数的。

A.Public Function Sum(x,y)

B.Public Function Sum(ByVal x, ByVal y)

C.Public Function Sum(x As Integer,y As Integer)

D.Public Function Sum(x%, y%)

18.以下过程的定义中,是错误的。

A. Public Sub Sum(x ; y)

B. Public Sub Sum(ByVal x, ByVal y)

C. Public Sub Sum(x As Integer,y As Integer)

D. Public Sub Sum(x%, y%)

19.在函数过程中的任意位置要退出当前函数过程,应用

A. End Function B. Exit C. Exit Function D. Exit Sub

20.在子过程中的任意位置要退出当前子过程,应用命令。

A. End Function B. Exit C. Exit Function D. Exit Sub

填空题

21.Private Sub P(b()As Integer)

For i=1 To 4

b(i)=2*i

Next i

End Sub

Private Sub Form_Click()

Dim a(1 To 4)As Integer

a(1)=2

a(2)=3

a(3)=4

a(4)=5

For i=1 To 4

Print a(i)

Next i

End Sub

运行上面的程序,单击命令按钮,输出结果为 。

22.本程序的功能是计算输入数的阶乘,请在画线处填上适当的内容使程序完整。 Private Sub Form_Click()

n=Val(InputBox("请输入一个大于0的整数: "))

Print Fact(n)

End Sub

Private Function Fact(m)

Fact=

For i=2 To Fact= Next i

End Function

相关推荐