- 相關(guān)推薦
計(jì)算機(jī)二級(jí)VB語(yǔ)言程序設(shè)計(jì)考試題及答案
不論從事何種工作,如果要想做出高效、實(shí)效,務(wù)必先從自身的工作計(jì)劃開始。有了計(jì)劃,才不致于使自己思想迷茫、頭腦空洞,不知從哪里著手開展工作。下面是小編搜索整理的計(jì)算機(jī)二級(jí)VB語(yǔ)言程序設(shè)計(jì)考試題及答案,供大家參考學(xué)習(xí)!
計(jì)算機(jī)二級(jí)VB語(yǔ)言程序設(shè)計(jì)考試題及答案
1.以下程序段運(yùn)行的結(jié)果為(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日
2.以下程序段運(yùn)行的結(jié)果為(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
3.以下程序段運(yùn)行的結(jié)果為(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
4.在窗體中建立一個(gè)文本框text1和一個(gè)命令按鈕command1,編寫下面程序:
Private Sub Text1_LostFocus( )
If Not IsNumeric(Text1) Then
MsgBox "帳號(hào)有非數(shù)字字符錯(cuò)誤"
Text1.Text = ""
Text1.SetFocus
else
MsgBox "帳號(hào)正確"
End If
End Sub
當(dāng)在text1文本框中輸入字符"abc"之后,單擊命令按鈕,結(jié)果為(B)(單)
A.顯示對(duì)話框,提示信息為"帳號(hào)正確"
B.顯示對(duì)話框,提示信息為"帳號(hào)有非數(shù)字字符錯(cuò)誤"
C.程序出錯(cuò)
D.沒(méi)有任何提示
5.在窗體中建立一個(gè)文本框text1和一個(gè)命令按鈕command1,編寫下面程序:
Private Sub Text1_LostFocus( )
If Not IsNumeric(Text1) Then
MsgBox "帳號(hào)有非數(shù)字字符錯(cuò)誤"
Text1.Text = ""
Text1.SetFocus
else
MsgBox "帳號(hào)正確"
End If
End Sub
當(dāng)在text1文本框中輸入數(shù)字123456之后,單擊命令按鈕,結(jié)果為(A)(單)
A.顯示對(duì)話框,提示信息為"帳號(hào)正確"
B.顯示對(duì)話框,提示信息為"帳號(hào)有非數(shù)字字符錯(cuò)誤"
C.程序出錯(cuò)
D.沒(méi)有任何提示
6.在窗體中建立一個(gè)文本框text1和一個(gè)命令按鈕command1,編寫下面程序:
Private Sub Command1_Click( )
Dim I As Integer
If Text1.Text <> "Gong" Then
I = MsgBox("密碼錯(cuò)誤", 5 + vbExclamation, "輸入密碼")
If I <> 4 Then
End
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
MsgBox "密碼帳號(hào)正確!"
End If
End Sub
若在text1中輸入字符串"Gong",則程序運(yùn)行結(jié)果為(A)(單)
A.顯示對(duì)話框,提示"密碼帳號(hào)正確!"
B.顯示對(duì)話框,提示"密碼錯(cuò)誤"
C.程序出錯(cuò)
D.沒(méi)有任何提示
7.在窗體中建立一個(gè)文本框text1和一個(gè)命令按鈕command1,編寫下面程序:
Private Sub Command1_Click( )
Dim I As Integer
If Text1.Text <> "Gong" Then
I = MsgBox("密碼錯(cuò)誤", 5 + vbExclamation, "輸入密碼")
If I <>4 Then
End
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
MsgBox "密碼帳號(hào)正確!"
End If
End Sub
若在text1中輸入字符串"gong",則程序運(yùn)行結(jié)果為(B)(單)
A.顯示對(duì)話框,提示"密碼帳號(hào)正確!"
B.顯示對(duì)話框,提示"密碼錯(cuò)誤"
C.程序出錯(cuò)
D.沒(méi)有任何提示
8.在窗體中建立一個(gè)文本框text1和一個(gè)命令按鈕command1,編寫下面程序:
Private Sub Command1_Click( )
Dim I As Integer
If Text1.Text <> "Gong" Then
I = MsgBox("密碼錯(cuò)誤", VbRetryCancle + vbExclamation, "輸入密碼")
If I <> 4 Then
End
Else
Text1.Text = ""
Text1.SetFocus
End If
Else
MsgBox "密碼帳號(hào)正確!"
End If
End Sub
若在text1中輸入字符串"123",顯示"密碼錯(cuò)誤"對(duì)話框,關(guān)于此對(duì)話框描述正確的是(A)(單)
A.顯示對(duì)話框中有“重試”按鈕
B.顯示對(duì)話框中有“確定”按鈕
C.顯示對(duì)話框中有“是”按鈕
D.以上說(shuō)法都不正確
9.在窗體中建立三個(gè)文本框,名稱分別為text1、text2和text3,還有一個(gè)名稱為label1的標(biāo)簽,一個(gè)名稱為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
當(dāng)在文本框text1、text2 和 text3 中分別輸入5、3和8,則標(biāo)簽顯示的結(jié)果為(C)(單)
A.3,5,8
B.5,3,8 C.8,5,3
D.3.8.5
10.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("請(qǐng)輸入1-4之間的整數(shù)"))
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
窗體運(yùn)行后,輸入1,則label1的.標(biāo)題顯示結(jié)果為(A)(單)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
11.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("請(qǐng)輸入1-4之間的整數(shù)"))
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
窗體運(yùn)行后,輸入2,則label1的標(biāo)題顯示結(jié)果為(B)(單)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
12.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("請(qǐng)輸入1-4之間的整數(shù)"))
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
窗體運(yùn)行后,輸入3,則label1的標(biāo)題顯示結(jié)果為(C)(單)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
13.以下程序段:
Private Sub Form_Load( )
Dim Nop As Integer, Op As String * 1
Num1 = 3
Num2 = 2
Nop = val(Inputbox("請(qǐng)輸入1-4之間的整數(shù)"))
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
窗體運(yùn)行后,輸入4,則label1的標(biāo)題顯示結(jié)果為(D)(單)
A.3+2=5
B.3-2=1
C.3×2=6
D.3÷2=1.5
14.以下程序段的作用是(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個(gè)表達(dá)式
B.打印九九乘法表,一行7個(gè)表達(dá)式
C.打印ASCII碼表,一行8個(gè)表達(dá)式
D.以上說(shuō)法都不正確
15.我國(guó)現(xiàn)在人口有13億,按人口增長(zhǎng)0.8%計(jì)算,多少年后我國(guó)人口將超過(guò)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.以上說(shuō)法都不正確
17.求自然數(shù)e的近似值,誤差小于0.00001,近似公式為:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用來(lái)求自然數(shù)e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和結(jié)果
I = 0 ' 計(jì)數(shù)器
n = 1 ' 存放階乘的值
t = 1 ' 級(jí)數(shù)第I項(xiàng)值
Do While 【t>】 0.00001
e = e + t
I = I + 1
n = n * I
t = 1 / n
Loop
Print "計(jì)算了 "; I; " 項(xiàng)的和是 "; e
End Sub
18.求自然數(shù)e的近似值,誤差小于0.00001,近似公式為:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用來(lái)求自然數(shù)e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和結(jié)果
I = 0 ' 計(jì)數(shù)器
n = 1 ' 存放階乘的值
t = 1 ' 級(jí)數(shù)第I項(xiàng)值
Do While t>0.00001
e = e + 【t】
I = I + 1
n = n * I
t = 1 / n
Loop
Print "計(jì)算了 "; I; " 項(xiàng)的和是 "; e
End Sub
19.求自然數(shù)e的近似值,誤差小于0.00001,近似公式為:e=1+1/1!+1/2!+1/3!+……+1/I!+……以下程序用來(lái)求自然數(shù)e。
Private Sub Form_Click( )
Dim I%, n&, t!, e!
E = 0 ' 存放累加和結(jié)果
I = 0 ' 計(jì)數(shù)器
n = 1 ' 存放階乘的值
t = 1 ' 級(jí)數(shù)第I項(xiàng)值
Do While t>0.00001
e = e + t
I = I + 1
n = n * 【I】
t = 1 / n
Loop
Print "計(jì)算了 "; I; "項(xiàng)的和是"; e
End Sub
20.以下程序是求最大公約數(shù)和最小公倍數(shù)的程序。
Private Sub Form_Click( )
Dim m1, n1, m, n, r As Integer
n1 = InputBox("輸入自然數(shù)n", "輸入數(shù)")
m1 = InputBox("輸入自然數(shù)m", "輸入數(shù)")
n = n1
m = m1
If m < n Then
t = m: m = n: n = t
End If
r = m Mod 【n】
Do While (r<>0)
m = n
n = r
r = m Mod n
Loop
Print "最大公約數(shù)=", n
Print "最小公倍數(shù)= ", m1 * n1 / n
End Sub
【計(jì)算機(jī)二級(jí)VB語(yǔ)言程序設(shè)計(jì)考試題及答案】相關(guān)文章:
計(jì)算機(jī)二級(jí)C語(yǔ)言考試題目09-25
計(jì)算機(jī)二級(jí)VB考試重點(diǎn)知識(shí)08-15
計(jì)算機(jī)二級(jí)考試VB選擇題試題08-09
計(jì)算機(jī)等級(jí)考試二級(jí)VB考點(diǎn):程序調(diào)試11-08
2014年計(jì)算機(jī)二級(jí)C語(yǔ)言模擬試題及答案(1)08-04
2014年計(jì)算機(jī)二級(jí)C語(yǔ)言模擬試題及答案(2)08-04
2014年計(jì)算機(jī)二級(jí)C語(yǔ)言模擬試題及答案(3)08-04
2016年計(jì)算機(jī)二級(jí)考試試題VB沖刺題08-06