单选题
VB
题号 #2273192
在窗体上画1个名称为Command1的命令按钮,然后编写下列程序:
Private Sub Command1_Click( )
Print fun("ABCDEFG")
End Sub
Function fun(st As String)As string
stlen=Len(st)
temp=""
For k=1 To stlen/2
temp=temp+Mid(st,k,1)+Mid(st,stlen-k+1,1)
Next k
fun=temp
End Function
程序运行时,单击命令按钮,则在窗体上显示的是( )。
参考答案
B
答案解析
B。【解析】Len函数返回Long,其中包含字符串内字符的数目,或是存储一变量所需的字节数,Mod 函数返回Variant(String),其中包含字符串中指定数量的字符。本题中Len(st)得到字符串“ABCDEFG”的
长度并将其赋给stlen,而For循环条件k从1到stlen/2即3,Mid(str,k,1)得到的是从字符串开始向后逐次取一个字符,Mid(str,stlen-k+1,1)则是从字符串尾部开始向前逐次取一个字符,易知temp中存放的是Mid(str,k,1)和Mid(St,stlen-k+1,1)的所有字符即AGBFCE。
长度并将其赋给stlen,而For循环条件k从1到stlen/2即3,Mid(str,k,1)得到的是从字符串开始向后逐次取一个字符,Mid(str,stlen-k+1,1)则是从字符串尾部开始向前逐次取一个字符,易知temp中存放的是Mid(str,k,1)和Mid(St,stlen-k+1,1)的所有字符即AGBFCE。
你可能感兴趣的试题
A.Private 3ub Form—DragDrop(Source As Control,X As Single,Y As Single)
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,X As Single,Y As Single)
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 Single,Y As Single)
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 Single,Y As Single)
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==13 Then
'回车符的ASCIl码是13
a=Val(Text1)
If a>=0 Or a<=100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
If KeyAscii==13 Then
'回车符的ASCIl码是13
a=Val(Text1)
If a>=0 Or a<=100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
B.Private Sub Textl—KeyPress(KeyAscii As Integer)
If KeyAseii=13 Then
'回车符的ASCIl码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Textl.SetFocus
Else
Text2.SetFocus:MsgBox("分数错")
End If
End If
End Sub
If KeyAseii=13 Then
'回车符的ASCIl码是13
a=Val(Text1)
If a>=0 And a<=100 Then
Textl.SetFocus
Else
Text2.SetFocus:MsgBox("分数错")
End If
End If
End Sub
C.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then
'回车符的ASCII码是13
a=Val(Text1)
If a<0 And a>100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
If KeyAscii=13 Then
'回车符的ASCII码是13
a=Val(Text1)
If a<0 And a>100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
D.Private Sub Text1_KeyPress(KeyAscii As Integer)
If KevAscii=13 Then
'回车符的ASCII码是13
a=Val(Textl)
If a>=0 Aad a<=100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub
If KevAscii=13 Then
'回车符的ASCII码是13
a=Val(Textl)
If a>=0 Aad a<=100 Then
Text2.SetFocus
Else
Text1.SetFocus:MsgBox("分数错")
End If
End If
End Sub

