vb 在给定的字符串中查找某个指定的字符第一次出现的位置.怎么编码

要求:运行时,在文本框中任意输入一个小写字幕后,即显示"X first occurs in position X".
如.在文本框中输入小写字母b,显示"B first occurs in position 11"
且文本框始终处于选中状态.

private sub text1_change()
dim a as string
dim b as string
a=label1.caption
b=ucase(text1.text)
pos=instr(a,b)
label4.caption=b & "" & pos
end sub

ucase会变成大写
处于选中状态:
text1.set focus
text1.selstart=0
text1.sellength=len(text1.text)
温馨提示:答案为网友推荐,仅供参考
相似回答