首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
设有下面程序代码: Private Sub Command1_Click() Dim str As String, ch As String str = "Visual Basic Programming" ch = "a"
设有下面程序代码: Private Sub Command1_Click() Dim str As String, ch As String str = "Visual Basic Programming" ch = "a"
admin
2020-07-22
44
问题
设有下面程序代码:
Private Sub Command1_Click()
Dim str As String, ch As String
str = "Visual Basic Programming"
ch = "a"
n = fun(ch, str)
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兼容($的作用是强制将函数的返回值设为字符型)。&用来连接字符串。If条件判断字符是否和输入的字符相等,相等则n加1。选B)。
转载请注明原文地址:https://www.kaotiyun.com/show/BVHp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
在考生文件夹下有一个工程文件Sjt5.vbp,考生文件夹下in5.dat文件中保存有一篇英文短文。程序运行时,单击“读取并统计”按钮,则按行读取in5.dat文件的内容,并显示到文本框Text1中,同时调用Calculate过程统计每个英文字母(不区分大小
在窗体上画1个命令按钮和1个文本框,其名称分别为Command1和Text1,再编写如下程序:DimssAsStringPrivateSubText1_KeyPress(KeyAsciiAsInteger) IfChr(KeyAsc
下列打开"代码窗口"的操作中错误的是( )。
编写如下程序:DimnumAsInteger,rAsInteger,nAsInteger,iAsIntegerDimarr(5)AsIntegerPrivateSubCommand1_Click()
在菜单编辑器中建立如下图所示的菜单,并为了每个菜单项编写了鼠标单击事件过程。关于此菜单,以下叙述中错误的是( )。
下列关于窗体的描述中,错误的是()。
以下关于过程及过程参数的描述中,错误的是()。
以下关于VB对象属性的叙述中,错误的是
VisualBasic中的“启动对象”是指启动VisualBasic应用程序时,被自动加载并首先执行的对象。下列关于VisualBasic“启动对象”的描述中,错误的是
在考生文件夹下有一个数据库文件“samp3.accdb”,其中存在已经设计好的表对象“tAddr”和“tUser”。同时还有窗体对象“fEdit”和“fEuser”。请在此基础上按照以下要求补充“fEdit”窗体的设计。(1)将窗体中名称为“Lr
随机试题
(76)Withinafewshortyears,girlsinEuropehavebecomeheaviersmokersthanboys,forreasonsexpertsstillfailtounderstan
A.亚铁盐B.氨苯蝶啶C.溴化钾D.巴比妥E.地高辛不宜与安宫牛黄丸合用的药物是
混悬剂的物理稳定性因素不包括()
一个基层预算单位开设一个零余额账户。()
甲、乙、丙、丁拟设立一个有限合伙企业,合伙协议中约定了如下内容,其中符合合伙企业法律制度规定的有()。
通过伪造某台主机的IP地址窃取特权的攻击方式属于()。
数据库管理系统是()。
Readthetextbelowabouthowtoorderproducts.Inmostofthelines41-52thereisoneextraword.Itiseithergrammatically
Sevenyearsago,whenIwasvisitingGermany,Imetwithanofficialwhoexplainedtomethatthecountryhadaperfectsolution
Thewaypeopleholdtothebeliefthatafun-filled,painfreelifeequalshappinessactuallyreducestheirchancesofever【B1】
最新回复
(
0
)