Click here to Skip to main content
15,887,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using some strings throughout my application to control user input. I call these control strings.
For example:
Public UCAlphaStr As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"


The problem is that I want to allow the user to input a double quote character, Chr(34) or " in one of the control strings.

Dim DblQuote As String = Chr(34)

PartNameStr = AlphaNumericStr & ",:-()#&%  ./" & DblQuote


When single-stepping through the code, the end of this string returns vbNullChar.

How do I add the double quote character to a string?

What I have tried:

I have searched on-line for solutions to this problem. One "solution" is essentially what I wrote above. It does not work (as I stated).
Posted
Updated 29-Apr-23 20:30pm

 
Share this answer
 
Double them up:
VB
Dim MyString as String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ""!$%^&*0123456789"
		Console.WriteLine(MyString)
Gives:
ABCDEFGHIJKLMNOPQRSTUVWXYZ"!$%^&*0123456789
 
Share this answer
 
Comments
Kevin Brady 30-Apr-23 9:55am    
Thank you. This solution works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900