Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

Take the &quote 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 &quote; in the stream.

"Nobody knows what I do until I stop doing it."
  • Leaders
Posted

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">

[sIGPIC]e[/sIGPIC]
Posted
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.
"Nobody knows what I do until I stop doing it."

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...