VBA中的引号 [英] Quotation marks in VBA

查看:235
本文介绍了VBA中的引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前的VBA代码中,我有一个查询,其中使用 Chr(34)在某些变量之间加上引号。

In my current VBA code, I have a query in which I am using Chr(34) to put quotation marks between some of my variables.

我想知道有什么替代方法。我知道,这是一个简单的问题,但是重复这样的引号并没有取得成功

I was wondering what alternatives exist to this. This is a simple question, i know, but I haven't had any success with repeating quotation marks like this


和此处的可变字符串&

" & variable string here & "

我的代码只是一团糟,对于不熟悉VBA的人来说是无法理解的:

My code is messy for one and not understandable for people who are not familiar with VBA:

comboService = Chr(34) & Me.Combo8.Value & Chr(34)

此外,此操作无效:

comboService = """" & Me.Combo8.Value & """"

你能告诉我为什么吗?

谢谢。

推荐答案

此:

comboService = """ & Me.Combo8.Value & """

是您发布的内容,但是您需要添加一个额外的引号以添加文字引号:

is what you posted, but you need to add an extra quotation mark in order to add a literal quotation mark:

comboService = """" & Me.Combo8.Value & """"

字符串中的双引号是您要查找的内容。

Double-quotes within a string are what you are looking for.

aVar = "This: "" is a literal quotation mark"

这篇关于VBA中的引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆