设有下面程序代码: Private Sub Command1_Click() Dim str As String,ch As String str="Visual Basic Programming" ch="a" n=fun(ch,st) Print s

admin2019-04-29  40

问题 设有下面程序代码:
Private Sub Command1_Click()
Dim str As String,ch As String
str="Visual Basic Programming"
ch="a"
n=fun(ch,st)
Print str,n
End Sub
Private Function fun(ch As String,str As String)
As Integer
Dim strbuf As String,C As String,n As Integer
For k=1 To Len(str)
C=Mid$(str,k,1)
If c< >ch Then
strbuf=strbuf&c
Else
strbuf=strbuf&UCase(C)
n=n+1
End If
Next k
str=strbuf
fun=n
End Function
程序运行时的输出是

选项 A、Visual Basic Programming 0
B、VisuAl BAsic ProgrAmming 3
C、Visul Bsic Progrmming 3
D、VisualBasicProgramming 2

答案B

解析 Mid$(A$,4,2)是为了与老版本的VB兼容($的作用是强制将函数的返回值设为字符型)。&用来连接字符串。Ⅱ条件判断字符是否和输入的字符相等,相等则n加1。选B。
转载请注明原文地址:https://kaotiyun.com/show/E1Up777K
0

最新回复(0)