简体   繁体   中英

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.

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

Because of the double quotes around the A, that value is not included in the drop-down-list, all other values are present.

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) & "'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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