此替换功能有什么问题?为什么不起作用?
Sub test()
MyString = "Armstrong has hamstring injury and his return is questionable"
Injury = " Hamstring "
NewString = Replace(MyString, Injury, "$InjType$", vbTextCompare)
MsgBox (NewString)
End Sub
预期答案:阿姆斯特朗(Armstrong)受伤$ InjType $,而他的返回值得怀疑
获得的答案:阿姆斯特朗(Armstrong)腿筋受伤,他的返回值得怀疑
请帮忙。提前致谢。
这是vbTextCompare
参数的错误位置。
您可以使用
NewString = Replace(MyString, Injury, "$InjType$", compare:=vbTextCompare)
或者
NewString = Replace(MyString, Injury, "$InjType$", , , vbTextCompare)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句