管理字符串 VBA 中的引号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20400068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Manage quotes inside string VBA
提问by omixam
I trying to insert to Access Table some values that I getting from another table, the problem is that some values comes with quotes and double quotes inside the string, like this example:
我试图将我从另一个表中获取的一些值插入到 Access 表中,问题是某些值在字符串中带有引号和双引号,如下例所示:
str1 = "Non-fusible sectionalizing "green' low rise switch."
How can I manage quotes inside string in VBA for Access 2010 for can insert it into table?
如何在 VBA for Access 2010 中管理字符串内的引号以便将其插入表中?
回答by Tanner
From memory I think you just need to double them up to look like this:
根据记忆,我认为您只需要将它们加倍即可,如下所示:
str1 = "Non-fusible sectionalizing ""green' low rise switch."
You can perform a Replace
on the string using Chr(34)
- the "
character:
您可以Replace
使用Chr(34)
-"
字符对字符串执行 a :
str1 = Replace(str1, Chr(34), Chr(34)&Chr(34))