iliekater 发表于 2007-8-27 14:19:32

替换 VBA 字符串中的 caracter

**** Hidden Message *****

Keith™ 发表于 2007-8-27 14:25:25

是的,使用Instr()找到它,在找到的位置添加它

Keith™ 发表于 2007-8-27 14:35:43

我使用<strong>替换<br>和<pre>Replace(expression, find, replace[, start[, count[, compare]]])
Public Sub Main()
    Dim strNewString As String
   
    strNewString = Replace("d:\\Program files\\Folder 1\\Sub folder 2", "\\", "\", 1)
    MsgBox strNewString
End Sub

Maverick® 发表于 2007-8-27 14:41:18

使用替换
Dim Path as String
Dim NewPath As String
Path = "d:\Program files\Folder 1\Sub folder 2"
NewPath = Replace (Path, "\", "\\")

新路径将等于“d:\\Program files\\Folder 1\\Sub Folder 2”
dangit..Matt击败了我…

iliekater 发表于 2007-8-27 14:42:01


哇哦!

Dnereb 发表于 2007-8-27 14:42:45


呜呜呜!!

我需要学习更快地打字...

iliekater 发表于 2007-8-27 15:01:26

我知道有一种更简单的方法,我只是不记得我的头顶上的REPLACE

Maverick® 发表于 2007-8-27 17:50:29


哇哦!

我需要学习更快地打字...

不,他只是比你上蜡和上蜡都多。

Keith™ 发表于 2007-8-27 18:27:46

谢谢你们。这将是有帮助的。

Keith™ 发表于 2007-8-30 10:22:33

C:\test\\\Stuff.dwg
公共函数 RemoveRepetitiveBackSlashes( StrText, Optional AlternativeString as String) as String
Dim StrFind as String
Dim StrDoulblure as String
if Len (Alternative) > 0 那么
StrFind = AlternativeString
else
StrFind = “\”
end if
StrDoublure = StrFind & StrFind
Do While( Len(RemoveRepetitiveSlashes )Len(StrText)
RemoveRepetitiveSlashes = StrText
StrText = Replace(StrText, “\”, “\\”)
loop
结束功能
页: [1]
查看完整版本: 替换 VBA 字符串中的 caracter