VB 在LABEL控件中改变某个字

来源:百度知道 编辑:UC知道 时间:2024/06/10 02:41:19
比如说,LABEL中含有"\\"字符,我想用一个按键把它改成"\"有没有办法,

label1.caption=replace(lable1.caption,"\\","\")

分析,搜到"\\"修改为"\"

在过程中添加
for i=1 to len(label1.caption)
if mid(label1.caption,i,2)="\\" then
label1.caption=left(label1.caption,i) & right(label1.caption,len(label1.caption)-i-1)
end if
if i>len(label1.caption) then exit for'主要目的是防止越标
next i

2L正解

修改下1L的

i=1
do while i< len(label1.caption)
if mid(label1.caption,i,2)="\\" then
label1.caption=left(label1.caption,i-1) & right(label1.caption,len(label1.caption)-i-1)
end if
i=i+1
loop