1.在窗体上画一个名称为Text1的文本框,一个名称为Command1的命令按钮,然后编写如下事件过程和通用过程:
Private Sub Command1_Click( )
n = Val(Text1.Text)
If n2 = n/2 Then
f = f1(n)
Else
f = f2(n)
End If
Print f; n
End Sub
Public Function f1(ByRef x)
x=x*x
f1=x+x
End Function
Public Function f2(ByVal x)
x=x*x
f2=x+x+x
End Function
程序运行后,在文本框中输入3,然后单击命令按钮,窗体上显示的是(D)(单)
A.72 36
B.108 36
C.72 6
D.27 3
2.在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程:
Private Sub Command1_Click( )
c = "1234"
For i = 1 To 4
c1 = Trim(Str( ))
Print c1
Next i
End Sub
程序运行后,单击命令按钮,要求在窗体上显示如下内容
1
12
123
1234
则在下划线处应填入的内容为(B)(单)
A.Right(c1,i)
B.Left(c1,i)
C.Mid(c1,i,1)
D.Mid(c1,i,i)
3.在窗体上画一个名称为Command1的命令按钮和一个名称为Text1的文本框,然后编写如下事件过程:
Private Sub Command1_Click( )
n = Val(Text1.Text)
For i = 2 To n
For j = 2 To sqr(i)
If i Mod j = 0 Then Exit For
Next j
If j >Sqr(i) Then Print i
Next i
End Sub
该事件过程的功能是(C)(单)
A.输出n以内的奇数
B.输出n以内的偶数
C.输出n以内的素数
D.输出n以内能被j整除的数
4.在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程:
Private Function f(m As Integer)
If m Mod 2 = 0 Then
f = m
Else
f = 1
End If
End Function
Private Sub Command1_Click( )
Dim i As Integer
s = 0
For i = 1 To 5
s = s + f(i)
Next
Print s
End Sub
程序运行后,单击命令按钮,在窗体上显示的是(C)(单)
A.11
B.10
C.9
D.8
5.在窗体上画一个名称为Text1的文本框和一个名称为Command1的命令按钮,然后编写如下事件过程:
Private Sub Command1_Click( )
Dim array1(10, 10) As Integer
Dim i As Integer, j As Integer
For i = 1 To 3
For j = 2 To 4
array1(i, j) = i + j
Next j
Next i
Text1.Text = array1(2, 3) + array1(3, 4)
End Sub
程序运行后,单击命令按钮,在文本框中显示的值是(D)(单)
A.15
B.14
C.13
D.12
6.Visual Basic应用程序中标准模块文件的扩展名是【BAS或.BAS】(注意不要写点)。
7.在菜单编辑器中建立一个菜单,其主菜单项的名称为mnuEdit,Visible属性为False,程序运行后,如果用鼠标右键单击窗体,则弹出与mnuEdit相应的菜单。
Private Sub Form_ 【mousedown】 (Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button=2 Then
popupmenu mnuEdit
End If
End Sub
8.在菜单编辑器中建立一个菜单,其主菜单项的名称为mnuEdit,Visible属性为False,程序运行后,如果用鼠标右键单击窗体,则弹出与mnuEdit相应的菜单。以下是实现上述功能的程序,请填空。
Private Sub Form mousedown (Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button=2 Then
【popupmenu】 mnuEdit
End If
9.为了使计时器控件Timer1每隔0.5秒触发一次Timer事件,应将Timer1控件的【Interval】属性设置为500。
10.为了使计时器控件Timer1每隔0.5秒触发一次Timer事件,应将Timer1控件的Interval属性设置为【500】。
11.与数学表达式ln(a+b)/(3x)+5 对应的Visual Basic表达式是【log(a+b)/(3*x)+5或(log(a+b)/(3*x))+5】
12.将C盘根目录下的图形文件moon.jpg装入图片框Picture1的语句是【】
13.在窗体上画一个名称为Text1的文本框,然后画三个单选按钮,并用这三个单选按钮建立一个控件数组,名称为Option1,程序运行后,如果单击某个单选按钮,则文本框中的字体将根据所选择的单选按钮切换。
Private Sub Option1_Click(Index As Integer)
Select Case 【Index】
Case 0
a = "宋体"
Case 1
a = "黑体"
Case 2
a = "楷体_GB2312"
End Select
text1.fontname=a
End Sub
14.在窗体上画一个名称为Text1的文本框,然后画三个单选按钮,并用这三个单选按钮建立一个控件数组,名称为Option1,程序运行后,如果单击某个单选按钮,则文本框中的字体将根据所选择的单选按钮切换。
Private Sub Option1_Click(Index As Integer)
Select Case index
Case 0
a = "宋体"
Case 1
a = "黑体"
Case 2
a = "楷体_GB2312"
End Select
text1.【fontname】=a
End Sub
15.在窗体上画两个组合框,其名称分别为Combo1、Combo2,然后画两个标签,名称分别为Label1、Label2。程序运行后,如果在某个组合框中选择一个项目,则把所选中的项目在其下面的标签中显示出来。
Private Sub Combo1_Click( )
Call ShowItem(Combo1, Label1)
End Sub
Private Sub Combo2_Click( )
Call ShowItem(Combo2, Label2)
End Sub
Public Sub ShowItem(tmpCombo As ComboBox, tmpLabel As Label)
【tmplabel】.Caption =tmpCombo.Text
End Sub
16.在窗体上画两个组合框,其名称分别为Combo1、Combo2,然后画两个标签,名称分别为Label1、Label2,程序运行后,如果在某个组合框中选择一个项目,则把所选中的项目在其下面的标签中显示出来。
Private Sub Combo1_Click( )
Call ShowItem(Combo1, Label1)
End Sub
Private Sub Combo2_Click( )
Call ShowItem(Combo2, Label2)
End Sub
Public Sub ShowItem(tmpCombo As ComboBox, tmpLabel As Label)
tmpLabel.Caption =【tmpcombo】.Text
End Sub
17.在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程:
Private Sub Command1_Click( )
n = 5
f = 1
s = 0
For c = 1 To n
f = f*【7】
s = s + f
Next c
Print s
End Sub
该事件过程的功能是计算1!+2!+3!+…+n!的值。
18.在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:
Option Base 1
Private Sub Command1_Click( )
Dim a(10) As Integer
For I = 1 To 10
a(I) = I
Next I
Call【swap】a( )
For I = 1 To 10
Print a(I);
Next
End Sub
Sub swap(b( ) As Integer)
n = ubound(b)
For I = 1 To n / 2
t = b(I)
b(I) = b(n)
b(n) = t
n=n-1
Next I
End Sub
上述程序的功能是,通过调用过程swap,调换数组中数值的存放位置,即a(1)与a(10)的值互换,a(2)与a(9)的值互换,……,a(5)与a(6)的值互换。
19.在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:
Option Base 1
Private Sub Command1_Click( )
Dim a(10) As Integer
For I = 1 To 10
a(I) = I
Next I
Call swap(a( ))
For I = 1 To 10
Print a(I);
Next
End Sub
Sub swap(b( ) As Integer)
n =【ubound(b)】
For I = 1 To n / 2
t = b(I)
b(I) = b(n)
b(n) = t
n=n-1
Next I
End Sub
上述程序的功能是,通过调用过程swap,调换数组中数值的存放位置,即a(1)与a(10)的值互换,a(2)与a(9)的值互换,……,a(5)与a(6)的值互换。
20.在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:
Option Base 1
Private Sub Command1_Click( )
Dim a(10) As Integer
For I = 1 To 10
a(I) = I
Next I
Call swap(a( ))
For I = 1 To 10
Print a(I);
Next I
End Sub
Sub swap(b( ) As Integer)
n = ubound(b)
For I = 1 To n / 2
t = b(I)
b(I) = b(n)
b(n) = t
n=【n-1】
Next I
21.以下程序段运行的结果为(B)(单)
Private Sub Form_Click( )
MyDate = #7/21/1997#
Print Format(MyDate, "m/d/yy")
Print Format(MyDate,"yyyy年m月dd日")
End Sub
A.7/21/97 1997年7月21日
B.7-21-97 1997年7月21日
C.97/7/21 1997年7月21日
D.7/21/97 97年7月21日
22.以下程序段运行的结果为(B)(单)
Private Sub Form_Click( )
MyTime = #9:21:30 PM#
MyDate = #7/21/1997#
Print Tab(2); Format(MyDate, "mmmm-yy")
Print Tab(2); Format(MyTime, "hh:mm:ss A/P")
End Sub
A.July-97 9:21:30 P
B.July-97 09:21:30 P
C.07-97 9:21:30 P
D.July-97 9:21:30
23.以下程序段运行的结果为(C)(单)
Private Sub Form_Click( )
MyDate = #7/21/1997#
Print Format(MyDate, "dddd,mmmm,dd,yyyy")
End Sub
A.21,07,1997
B.21,07,21,1997
C.Monday,July,21,1997
D.Monday,07,21,1997
24.在窗体中建立一个文本框text1和一个命令按钮command1,编写下面程序:
Private Sub Text1_LostFocus( )
If Not IsNumeric(Text1) Then
MsgBox "帐号有非数字字符错误"
Text1.Text = ""
Text1.SetFocus
else
MsgBox "帐号正确"
End If
End Sub
当在text1文本框中输入字符"abc"之后,单击命令按钮,结果为(B)(单)
A.显示对话框,提示信息为"帐号正确"
B.显示对话框,提示信息为"帐号有非数字字符错误"
C.程序出错
D.没有任何提示
25.在窗体中建立一个文本框text1和一个命令按钮command1,编写下面程序:
Private Sub Text1_LostFocus( )
If Not IsNumeric(Text1) Then
MsgBox "帐号有非数字字符错误"
Text1.Text = ""
Text1.SetFocus
else
MsgBox "帐号正确"
End If
End Sub
当在text1文本框中输入数字123456之后,单击命令按钮,结果为(A)(单)
A.显示对话框,提示信息为"帐号正确"
B.显示对话框,提示信息为"帐号有非数字字符错误"
C.程序出错
D.没有任何提示
26.在窗体中建立一个文本框text1和一个命令按钮command1,编写下面程序:
Private Sub Command1_Click( )
Dim I As Integer
If Text1.Text <> "Gong" Then
I = MsgBox("密码错误", 5 + vbExclamation, "输入密码")
If I <> 4 Then
End
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
MsgBox "密码帐号正确!"
End If
End Sub
若在text1中输入字符串"Gong",则程序运行结果为(A)(单)
A.显示对话框,提示"密码帐号正确!"
B.显示对话框,提示"密码错误"
C.程序出错
D.没有任何提示
27.在窗体中建立一个文本框text1和一个命令按钮command1,编写下面程序:
Private Sub Command1_Click( )
Dim I As Integer
If Text1.Text <> "Gong" Then
I = MsgBox("密码错误", 5 + vbExclamation, "输入密码")
If I <>4 Then
End
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
MsgBox "密码帐号正确!"
End If
End Sub
若在text1中输入字符串"gong",则程序运行结果为(B)(单)
A.显示对话框,提示"密码帐号正确!"
B.显示对话框,提示"密码错误"
C.程序出错
D.没有任何提示
28.在窗体中建立一个文本框text1和一个命令按钮command1,编写下面程序:
Private Sub Command1_Click( )
Dim I As Integer
If Text1.Text <> "Gong" Then
I = MsgBox("密码错误", VbRetryCancle + vbExclamation, "输入密码")
If I <> 4 Then
End
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
MsgBox "密码帐号正确!"
End If
End Sub
若在text1中输入字符串"123",显示"密码错误"对话框,关于此对话框描述正确的是(A)(单)
A.显示对话框中有“重试”按钮
B.显示对话框中有“确定”按钮
C.显示对话框中有“是”按钮
D.以上说法都不正确
29.在窗体中建立三个文本框,名称分别为text1、text2和text3,还有一个名称为label1的标签,一个名称为command1的命令按钮,编写如下代码:
Private Sub Command1_Click( )
Dim x!, y!, z!, t!
x = Text1
y = Text2
z = Text3
If x < y Then
t = x
x = y
y = t
End If
If y < z Then
t = y
y = z
z = t
If x< y Then
t = x
x = y
y = t
End If
End If
Label1.Caption = x & "," & y & "," & z
End Sub
当在文本框text1、text2 和 text3 中分别输入5、3和8,则标签显示的结果为(C)(单)
A.3,5,8
B.5,3,8 C.8,5,3
D.3.8.5
30.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入1,则label1的标题显示结果为(A)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
31.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入2,则label1的标题显示结果为(B)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
32.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入3,则label1的标题显示结果为(C)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
33.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("请输入1-4之间的整数"))
Select Case Nop
Case 1
Op = "+"
Result = Num1 + Num2
Case 2
Op = "-"
Result = Num1 - Num2
Case 3
Op = "×"
Result = Num1 * Num2
Case 4
Op = "÷"
Result = Num1 / Num2
End Select
Label1= Num1 & Op & Num2 & "=" & Result
End Sub
窗体运行后,输入4,则label1的标题显示结果为(D)(单)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
34.以下程序段的作用是(A)(单)
Private Sub Picture1_Click( )
Dim asci As Integer, i As Integer
i = 0
For asci = 32 To 126
Picture1.Print Tab(7 * i + 2); Chr(asci); "="; asci;
i = i + 1
If i = 7 Then i = 0: Picture1.Print
Next asci
A.打印ASCII码表,一行7个表达式
B.打印九九乘法表,一行7个表达式
C.打印ASCII码表,一行8个表达式
D.以上说法都不正确
35.我国现在人口有13亿,按人口增长0.8%计算,多少年后我国人口将超过26亿。
Private Sub Command1_Click( )
Dim x, n
x = Val(Text1)
n = 0
Do While 【x】<26
x = x * (1 + 0.008)
n = n + 1
Loop
Text2 = Str(n)
End Sub
16.以下程序的作用是(B)(单)
For i = 1 To 9
For j = 1 To 9
se = i & "×" & j & "=" & i * j
Picture1.Print Tab((j - 1) * 9 + 1); se;
Next j
Picture1.Print
Next i
A.打印ASCII码表
B.打印九九乘法表
C.打印加法表
D.以上说法都不正确
37.求自然数e的近似值,误差小于0.00001,近似公式为:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用来求自然数e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和结果
评论
全部评论(0)
还没有评论,快来抢沙发吧!