SlowLearner Posted February 22, 2005 Posted February 22, 2005 Hi I am not sure if this is the right place to post this question, and I am rather unfamiliar with VB.Net. I need to code out a proper HTML file using VB.NET including tables so that the HTML code will look similiar to this: <table width="500" border="1" cellspacing="1" cellpadding="1"> I know that " is supposed to replace " but when I add that to a string, my final HTML file comes out along the lines of: <table width="500" border="1" cellspacing="1" cellpadding = "1" > :confused: I am currently using the StreamWriter function and writing in strings to compile the HTML file. Something like this <code> Dim str As String Dim str2 As String Dim str3 As String Dim str4 As String Dim objStr As StreamWriter objStr = New StreamWriter("c:\test.html") str = "<table width="500"" str2 = "border="1"" str3 = "cellspacing="1"" str4 = "cellpadding = "1" >" objStr.WriteLine(str) objStr.WriteLine(str2) objStr.WriteLine(str3) objStr.WriteLine(str4) objStr.Close() </code> Is anyone able to help/guide me along? Or am I doing something wrong? Thanks in advance. Quote
Rick_Fla Posted February 22, 2005 Posted February 22, 2005 Take the "e out and use the following. I don't have VS opened, but should be fine. Dim str As String Dim str2 As String Dim str3 As String Dim str4 As String Dim objStr As StreamWriter objStr = New StreamWriter("c:\test.html") str = "<table width=" & Chr(34) & "500" & char(34) str2 = "border=" & Chr(34) & "1" & Chr(34) str3 = "cellspacing=" & chr(34) & "1" & chr(34) str4 = "cellpadding = " & chr(34) & "1" & chr(34) & " >" objStr.WriteLine(str) objStr.WriteLine(str2) objStr.WriteLine(str3) objStr.WriteLine(str4) objStr.Close() the chr(34) is a quote and should work better than putting the "e; in the stream. Quote "Nobody knows what I do until I stop doing it."
Leaders snarfblam Posted February 22, 2005 Leaders Posted February 22, 2005 In VB you may include double quotes inside a string by putting double double quotes. Better yet... let me show you: Dim A As String = "String with ""Quotes"" inside" 'A = String with "Quotes" inside Dim B As String = """Quotes at the beginning and end can look confusing""" 'B = "Quotes at the beginning and end can look confusing" Dim C As String = "<table width=""500"" border=""1"">" 'C = <table width="500" border="1"> Quote [sIGPIC]e[/sIGPIC]
Rick_Fla Posted February 22, 2005 Posted February 22, 2005 Yes, you're right on the double quotes. I have used both, but have found myself getting confused or screwing up with all the quotes :) But I guess it's more of how comfortable you feel. Quote "Nobody knows what I do until I stop doing it."
SlowLearner Posted February 23, 2005 Author Posted February 23, 2005 Many thanks to the both of you for your help. It works fine now. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.