Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to print strings with quotations in VB.NET
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/4835691/escape-double-quote-in-vb-string">Escape double quote in VB string</a> </p> </blockquote> <p>I am assigning variables below with string values, and I would like to print these with quotations, although I am not sure how to accomplish this. So far everything prints fine, except for without quotations. What I have is below:</p> <pre><code> Dim tU As String = "Print_Me" Dim tU2 As String = "" Dim str1 As Integer = 1 Dim str2 As String = tU Dim str3 As Single = 3.5 Dim str4 As String = tU2 Dim fw As New System.IO.StreamWriter("testfile.txt") fw.WriteLine(str1 &amp; "," &amp; str2 &amp; "," &amp; str3 &amp; "," &amp; str4 &amp; "," &amp; 0) fw.Close() fw.Dispose() 'prints&gt;&gt;&gt;1,Print_Me,3.5,,0&lt;&lt;&lt; 'I like to print&gt;&gt;&gt;1,"Print_Me",3.5,"",0&lt;&lt;&lt; </code></pre> <p>EDIT</p> <pre><code> Dim tU As String = "Print_Me" Dim tU2 As String = "" Dim str1 As Integer = 1 Dim str2 As String = tU Dim str3 As Single = 3.5 Dim str4 As String = tU2 Dim str5 As Integer = 0 Using fw As New System.IO.StreamWriter("testfile.txt") fw.WriteLine(String.Format("""{0}"",""{1}"",""{2}"",""{3}"",""0""", str1, str2, str3, str4, str5)) End Using ''Currently prints&gt;&gt;&gt; "1","Print_Me","3.5","","0" ''I would like to print&gt;&gt;&gt; 1,"Print_Me",3.5,"",0 </code></pre> <p>I am indirectly populating str1 through str5, but I do not want to print all of the items with quotations, so how might I adjust the solution to accomplish this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload