VB用Replace()替换字符,怎么判断是否替换成功

2025-02-26 04:04:22
推荐回答(2个)
回答1:

举例:
s = "ffffffffffff"
s2 = Replace(s, "hh", "a")
If s2 = s Then MsgBox "没有替换"
If s2 <> s Then MsgBox "有替换"

s = "ffffffffffff"
s2 = Replace(s, "f", "a")
If s2 = s Then MsgBox "没有替换"
If s2 <> s Then MsgBox "有替换"

回答2:

方法很多。楼上就很好。