计算机二级

运行下列程序:Private Sub form_Click( )Dim sl As String, s2 As Strings1 = "1234&quo运行下列程序:Private Sub form_Click( )Dim sl As String, s2 As Strings1 = "1234"m = 0For i = 3 To 1 Step -1m = m + 1s2 = fun1(s1, m)Debug.Print s2;Next iEnd SubPrivate Function fun1(x, y

题目
运行下列程序:Private Sub form_Click( )Dim sl As String, s2 As Strings1 = "1234&quo

运行下列程序:

Private Sub form_Click( )

Dim sl As String, s2 As String

s1 = "1234"

m = 0

For i = 3 To 1 Step -1

m = m + 1

s2 = fun1(s1, m)

Debug.Print s2;

Next i

End Sub

Private Function fun1(x, y) As String

fun1 = Right(x, y)

End Function

单击窗体后,则在立即窗口内显示结果是( )。

A.1234

B.4321

C.434234

D.1111

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

有如下程序:

Private Sub Form_Click()

Dim i As Integer,Sum As Integer

Sum=0

For i=2 To 10

If i Mod 2<>0 And i Mod 3=0 Then

Sum=Sum+i

EndIf

Next

Print Sum

End Sub

程序运行后,单击窗体,输出结果为

A.12

B.30

C.24

D.18


正确答案:A
解析:本题考查的是For循环语句和If条件语句的应用。从本题可以看出,本题程序段的作用是将从2~10中不是2的倍数但是3的倍数的数相加然后输出。在2~10中满足条件的数字是3和9,所以和是12。

第2题:

设有如下程序:

Private Sub Form_Click()

Dim n As Integer, s As Integer

n = 8

s = 0

Do

s = s + n

n = n - 1

Loop While n > 0

Print s

End Sub

以上程序的功能是______。程序运行后,单击窗体,输出结果为______。


正确答案:

 求1-8的和 36

第3题:

下列程序的执行结果为

Private Sub Command1_Click()

Dim s1 As String, s2 As String

s1= "abcd"

Call Transfer(s1, s2)

Print s2

End Sub

Private Sub Transfer (ByVal xstr As String, ystr As String)

Dim tempstr As String

i=Len(xstr)

Do While i >=1

tempstr=tempstr + Mid(xstr, i, 1)

i=i - 1

Loop

ystr=te mpstr

End Sub( )。

A.dcba

B.abdc

C.abcd

D.dabc


正确答案:A

第4题:

在窗体上画一个命令按钮和两个文本框,其名称分别为Command1、Text1和Text2,然后编写如下程序: Dim S1 As String,S2 As String Private Sub Form_Load() Text1.Text="" Text2.Text="" End Sub Private Sub Text1_KeyDown(KeyCode As Integer,Shift As Integer) S2=S2 & Chr(Keycode) End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) S1=S1 & Chr(KeyAscii) End Sub Private Sub Command1_Click() Text1.Text=S2 Text2.Text=S1 S1="" S2="" End Sub 程序运行后,在Text1中输入“abc”,然后单击命令按钮,在文本框Text1和Text2中显示的内容分别为______。

A.abc和ABC

B.abc和abe

C.ABC和abc

D.ABC和ABC


正确答案:C
解析:KeyPress事件是处理用户按键的事件过程,当用户按键时激发该事件。KeyDown事件也是在用户按下按键时发生。但是KeyDown事件过程的KeyCode参数与KeyPress事件的KeyAscii参数不同。对于KeyPress事件的KeyAscii参数来说,小写状态下按A键返回97,而对于KeyDown事件过程的KeyCode参数来说返回65,由此可判断选项C为正确答案。

第5题:

设有如下程序:

Private Sub Form_Click()

Dim i As Integer,x As String,Y As String

x=”ABCDEFG”

For i=4 To 1 Step-1

y=Mid(x,i,i)+y

Next i

Print y

End Sub

程序运行后,单击窗体,输出结果为

A.ABCCDEDEFG

B.AABBCDEFG

C.ABCDEFG

D.AABBCCDDEEFFGG


正确答案:A
解析:本题Mid函数的功能是从第i个字符开始取i个,当i=4时,从字母D开始取到G,并加在y的开头,当i=3时,从字母C开始取到E,并加在y的开头,当i=2时,从字母B开始取到C,并加在y的开头,当i=1时,只取字母A,并加在y的开头,因此本题答案为A)。

第6题:

阅读下面的程序:

Private Sub Form_Click()

Dim Check As Boolean, Counter As Integer

Check = True

Counter = 5

Do

Do While Counter < 20

Counter = Counter + 1

If Counter = 10 Then

Check = False

Exit Do

End If

Loop

Loop Until Check = False

Print Counter

End Sub

程序运行后,单击窗体,输出结果为______。


正确答案:

10

第7题:

下列程序,当单击窗体时s的值是( )

Private Sub Form_Click()

Dim s As Integer

s = Not 2 * 5<>11

Print s

End Sub

A. True

B. False

C.1

D.0


正确答案:D

第8题:

单击窗体时,下列程序的执行结果是

Private Sub Invert(ByVal xstr As String, ystr As String)

Dim tempstr As String

Dim I As Integer

I=Len(xstr)

Do While I >=1

tempstr=tempstr + Mid(xstr, I, 1)

I=I - 1

Loop

ystr=tempstr

End Sub

Private Sub Form_Click()

Dim s1 As String, s2 As String

s1= "abcdef"

Invert s1, s2

Print s2

End Sub( )。

A.abcdef

B.afbecd

C.fedcba

D.defabc


正确答案:C

第9题:

下列程序运行时输出的结果是( )。 Option Base 1 Private Sub Form_Click() Const a=6 Dim x (a) As Integer For I=1 to a x(i)=1^2 Next I Print x(i) End Sub

A.36

B.25

C.1

D.出错信息


正确答案:D

第10题:

有弹出式菜单的结构如下表,程序运行时,单击窗体则弹出如下图所示的菜单。下面的事件过程中能正确实现这一功能的是( )。

A.Private Sub Form_Click() PopupMenu cut End Sub

B.Private Sub Command1_Click() PopupMenu edit End Sub

C.Private Sub Form_Click() PopupMenu edit End Sub

D.Private Sub Form_Click() PopupMenu cut End Sub


正确答案:C
解析:PopupMenu方法用来显示弹出式菜单,其格式为:[对象.]。PopupMenu菜单名[,Flags] [,X,Y,][BoldCommand]。根据题意,为了显示菜单,所以要把PopupMenu方法放到Form. Click事件中,菜单名为edit,所以选c。

更多相关问题