Quotes and Strings in VB.net

phantom404

Golden Member
Nov 2, 2004
1,460
2
81
I wrote a small command line based program to convert xlsx and xls files to comma delimited. Now I am trying to make it to where field framers are put around every field. (ex. "field1","Field2") The problem is no matter what I try I wind up getting """field1""","""field2""". Below is what I have tired so far.

xlsheet.Cells(i, i2).value = Chr(34) & Storage & Chr(34)
xlsheet.Cells(i, i2).value = """" & Storage & """"
xlsheet.Cells(i, i2).value = "\" & Storage & \""

Im using vb.net 2010. Any help would be appriciated.

Thanks!

****UPDATE****
I threw in a debugging statement to show a msgbox of the cell contents before and after I added the " and the cell contents is correct..it shows "field". So I'm guessing it has to do with when I'm saving and here is my statement.

xlsheet.SaveAs(Filename:=finalfile, FileFormat:=Excel.XlFileFormat.xlCSV) 'saves format in csv format
 
Last edited:

PhatoseAlpha

Platinum Member
Apr 10, 2005
2,131
21
81
What's the value of Storage itself? Maybe it's already got quotes, and you're adding more.

at any rate, convoluted but:

xlsheet.Cells(i, i2).value = controlchars.quote & Storage.trim(controlchars.quote).trimend(controlchars.quote) & controlchars.quote
 
Last edited:

phantom404

Golden Member
Nov 2, 2004
1,460
2
81
If I leave off the quotes I try to add, the output file looks like.... field1,field2,field3. Storage is just the contents of the excel cell.

I tried your solution and for some reason I keep getting the same 3 quotes on each side. :\

Ohh and thanks for the quick reply
 
Last edited: