VB代码求解~~~急知道答案啊~~~~谢谢了~~~

来源:百度知道 编辑:UC知道 时间:2024/05/05 22:11:18
这题是这样的
编写程序,将文本框中的内容进行压缩。方法如下:如果某字符出现一次,保留该数;如果某字符出现多次,只保留一个,删除其余重复出现的字符,并在每个字符后显示其出现的次数。
有两个 TEXT 两个command 控件哦

dim n ,m as integer
dim str as string
for n=1 to len(text1.text)
text1.seltext=left(text1.text,n)
str=text1.seltext '先保存当前搜索的字符
times=instr(text1.text,text1.seltext)
if times>0 then
text1.selstart=times-1
text1.sellength=1
text1.seltext=""
m=m+1
end if
text1.text=str & "[" & m "]" & text1.text
next

我没运行过,直接打出来的,应该会有错 =.=

没看到例子..