单选题
VB
题号 #2536765
在窗体上画1个名称为Co mmand1的命令按钮,然后编写下列程序:
Private Sub Co mmand1_Click()
Print fun("ABCDEFG")
End Sub
Function fun(st As Stri ng)As stri ng
stlen =Len(st)
te mp =""
For k =1To stlen/2
te mp =te mp +Mid(st ,k ,1)+Mid(st ,stlen -k +1,1) Next k fun =te mp
End Function
程序运行时,单击命令按钮,则在窗体上显示的是( )。
参考答案
B
答案解析
Len 函数返回Long ,其中包含字符串内字符的数目,或是存储一变量所需的字节数,Mod 函数返回Variant(Stri ng),其中包含字符串中指定数量的字符。本题中Len(st)得到字符串"ABCDEFG"的长度并将其赋给stlen ,而For 循环条件k 从1到stlen/2即3,Mid(str ,k ,1)得到的是从字符串开始向后逐次取一个字符,Mid(str ,stlen-k +1,1)则是从字符串尾部开始向前逐次取一个字符,易知te mp 中存放的是Mid(str ,k ,1)和Mid(st ,stlen -k +1,1)的所有字符即AGBFCE。故应选B。
你可能感兴趣的试题
A.Private Sub Form_DragDrop(Source As Control ,XAs Si ngle ,Y As Si ngle)
banana . Move Picture1 . Left +X,Picture1 . Top +Y
End Sub
banana . Move Picture1 . Left +X,Picture1 . Top +Y
End Sub
B.Private Sub banana_DragDrop(Source As Control ,XAs Si ngle ,Y As Si ngle)
Source . Move Picture1 . Left +X,Picture 1 . Top +Y
End Sub
Source . Move Picture1 . Left +X,Picture 1 . Top +Y
End Sub
C.Private Sub Picture1_DragDrop(Source As Control ,X As Si ngle ,Y As Si ngle)
Source . Move Picture1 . Left +X,Picture1 . Top +Y
End Sub
Source . Move Picture1 . Left +X,Picture1 . Top +Y
End Sub
D.Private Sub Picture1_DragDrop(Source As Control ,X As Si ngle ,Y As Si ngle)
banana . Move banana . Left +X,banana . Top +Y
End Sub
banana . Move banana . Left +X,banana . Top +Y
End Sub
A.15
B.13
C.11
D.9
A.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii =13Then
回车符的ASCII 码是13
a=Val(Text1)
If a >=0Or a <=100Then
Text2 . SetFocus
Else
Text1 . SetFocus :MsgBox ("分数错")
End If
End If
End Sub
If KeyAscii =13Then
回车符的ASCII 码是13
a=Val(Text1)
If a >=0Or a <=100Then
Text2 . SetFocus
Else
Text1 . SetFocus :MsgBox ("分数错")
End If
End If
End Sub
B.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii =13Then 回车符的ASCII 码是13
a=Val(Text1)
If a >=0And a <=100Then
Text1 . SetFocus
Else
Text2 . SetFocus :MsgBox ("分数错")
End If
End If
End Sub
If KeyAscii =13Then 回车符的ASCII 码是13
a=Val(Text1)
If a >=0And a <=100Then
Text1 . SetFocus
Else
Text2 . SetFocus :MsgBox ("分数错")
End If
End If
End Sub
C.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii =13Then 回车符的ASCII 码是13
a=Val(Text1)
If a <0And a >100Then
Text2 . SetFocus
Else
Text1 . SetFocus :MsgBox ("分数错")
End If
End If
End Sub
If KeyAscii =13Then 回车符的ASCII 码是13
a=Val(Text1)
If a <0And a >100Then
Text2 . SetFocus
Else
Text1 . SetFocus :MsgBox ("分数错")
End If
End If
End Sub
D.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii =13Then 回车符的ASCII 码是13
a=Val(Text1)
If a >=0And a <=100Then
Text2.SetFocus
Else
Text1.SetFocus :MsgBox ("分数错")
End If
End If
End Sub
If KeyAscii =13Then 回车符的ASCII 码是13
a=Val(Text1)
If a >=0And a <=100Then
Text2.SetFocus
Else
Text1.SetFocus :MsgBox ("分数错")
End If
End If
End Sub

