Question Multiple quotations on one line

Fluffy

New member
Joined
Nov 18, 2010
Messages
1
Programming Experience
Beginner
Forgive me all for being new and also forgive me for being a beginner at VB.net.

Basically I'm trying to code a program to output class names for a game which then allows the user to copy and paste the string of class names into the game itself.

The template for class names in the game look like this ["name",quantity];

So in the code for btn_add I have (which outputs to a text box):

txt_name.Text = ("['" & name & "'" & "," & quantity & "]" & ";" & " ") + txt_name.Text
Which in turn looks like: ['one',1];

Not the "s that I'm looking for.

How can I change the ' into "s without VB.net throwing up errors?

Thank you all.
 
Simply use two " inside string literals. You can see they do that here: String Data Type (Visual Basic)

"]" & ";" & " "
This is really overcomplicating this string: "]; "

Further, String.Format will make building such combined strings and variables much simpler:
VB.NET:
txt_name.Text = String.Format("[""{0}"",{1}]; {2}", name, quantity, txt_name.Text)
or if you want to leave the existing content out the equation:
VB.NET:
txt_name.Text = String.Format("[""{0}"",{1}]; ", name, quantity) & txt_name.Text
 
Back
Top