简体   繁体   English

VBA:在字符串中的单个字符周围转义双引号

[英]VBA: Escape double quotes around a single character within a string

I am facing a problem that I hope I can get some help in this forum.我遇到了一个问题,我希望我能在这个论坛上得到一些帮助。 I am retrieving values from a SQL Server data-table, loading them into an array to then use the array to add the items to a drop-down-list.我正在从 SQL Server 数据表中检索值,将它们加载到数组中,然后使用该数组将项目添加到下拉列表中。

The problem that I have is that one of the values contains double quotes around one of the characters of the string.我遇到的问题是其中一个值在字符串的一个字符周围包含双引号。

This is the value: "A" Side Music, LLC这就是价值:“A”Side Music, LLC

Because of the double quotes around the A, that value is not included in the drop-down-list, all other values are present.由于 A 周围的双引号,该值不包含在下拉列表中,所有其他值都存在。

The code that I have tried is this piece:我试过的代码是这一段:

    For intRecord = 0 To UBound(arrRecords, 2)

        Name.AddItem (Chr(34) & arrRecords(0, intRecord) & Chr(34))

    Next intRecord

Is there any way someone could help me figure how to work around this problem?有什么办法可以帮助我弄清楚如何解决这个问题?

Many thanks非常感谢

UPDATE更新

I am including a screen shot of a watch I added to demonstrate that the value is being retrieved.我包含了我添加的手表的屏幕截图,以证明正在检索该值。

在此处输入图片说明

将信息输入到 ListBox 时,MSAccess 需要在字符串周围加上单引号:

Name.AddItem "'" & arrRecords(0, intRecord) & "'"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM