vb用replace如何实现大小写自动替换?
我的意思是,假设我有以下代码:“afnwoerwenoDFNOwneoNOESRNwOenrwonF nwoeONESRnwo wWon”,其中里面都多个“wo”这个单词(标记红色的,并切不区分大小写),我如何用replace自动将“wo”自动替换成“#wo#”呢?得到的内容应该是:“afn#wo#erwenoDFNOwneoNOESRN#wO#enr#wo#nF n#wo#eONESRn#wo# w#Wo#n”,如何做呢?谢谢!
Sub test()
Dim w1 As String, w2 As String, fStr As String, i As Integer
w1 = "afnwoerwenoDFNOwneoNOESRNwOenrwonF nwoeONESRnwo wWon"
fStr = "wo"
Do
If Len(w1) = 0 Then Exit Do
i = InStr(1, w1, fStr, vbTextCompare)
If i = 0 Then Exit Do
w2 = w2 & Left$(w1, i - 1) & "#" & Mid$(w1, i, Len(fStr)) & "#"
w1 = Right$(w1, Len(w1) - (i + Len(fStr) - 1))
Loop
Debug.Print w2
End Sub