在VB中替换引号时如何在替换函数中使用转义字符

发布于 2024-07-23 03:08:04 字数 365 浏览 7 评论 0原文

这是我的代码片段:

 Public Function convert(ByVal robert As String)
        Try
            robert = Replace(robert, "U", "A")
            robert = Replace(robert, "\"", "A")

我实际上想用 A 替换“引号”,但程序似乎没有识别出我在 VB 中使用转义字符的事实。 有谁知道为什么? 谢谢!

Robert

由 rlbond86 编辑:这显然是 Visual Basic 代码。 我更改了标题和文字以反映这一点。

Here is my code snippet:

 Public Function convert(ByVal robert As String)
        Try
            robert = Replace(robert, "U", "A")
            robert = Replace(robert, "\"", "A")

I want to actually replace the "quotations" with the A but the program doesn't seem to recognize the fact that I'm using an escape character in VB. Does anyone know why? Thanks!

Robert

EDIT by rlbond86: This is clearly Visual Basic code. I have changed the title and text to reflect that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠檬色的秋千 2024-07-30 03:08:04

看起来像VB,而不是C++。

请参阅http://www.codingforums.com/archive/index.php/ t-20709.html

您想要使用:

robert = Replace(robert, chr(34), "A")

robert = Replace(robert, """", "A")

使用“作为转义字符

另请参阅:http://www.codecodex.com/wiki/index.php?title=Escape_sequences 有关多种语言的转义序列的信息

Looks like VB, not c++.

See http://www.codingforums.com/archive/index.php/t-20709.html

you want to use:

robert = Replace(robert, chr(34), "A")

or

robert = Replace(robert, """", "A")

using " as escape character

also see: http://www.codecodex.com/wiki/index.php?title=Escape_sequences For info on escape sequences in multiple languages

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文