Archived

This topic is now archived and is closed to further replies.

VB Help - HTML or just lots of "print" functions

This topic is 5178 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok i use VB 6.0 what's happening is i'm doing a hockey franchise thing on a hockey board - and to keep my stats professional looking i'm using the NHL.com style game summary. what i want to do is make a VB program where i can enter the numbers (all the info from the game) and create an HTML or TEXT (that i can save as HTML after) file from that here is what the NHL.com summaries look like http://www.nhl.com/onthefly/scoreboard/htmlreports/GS020022.HTM basically i need a VB program to take my input (as shown exactly on that score card - all the names, goals, penalties, teams, etc) and then create an HTML page or a TEXT document EXACTLY like the link i've shown you (in other words - i need it to write all the HTML source code). and i need it to put in my values... generally i can do something easy like
open ("c:\text.txt") for output as #1

Print, #1,"<tr>"
Print, #1,"<td align=right >1</td>"
Print, #1,"<td align=center>1</td>"
Print, #1,"<td align=right >16:13</td>"
Print, #1,"<td align=center>STL</td>"
Print, #1,"<td align=left  >K. TKACHUK (2)</td>"
Print, #1,"<td align=left  >D. WEIGHT (1)</td>"
Print, #1,"<td align=left  >A. MACINNIS (2)</td>"
Print, #1,"<td align=left  > 7  2 39 38 30 15</td>"
Print, #1,"<td align=left  > 1 53 52 13 </td>"
Print, #1,"<td align=center>PP</td>"
Print, #1,"</tr>"

close #1
    
however, when i need the html code to involve a " character - it won't work (such as an image tag). With the Print statement the " ends the input. so that won't work for all of the code... i had done one of these by just going in the HTML code in notepad and doing it all manually - but it takes too long. i'm wondering if there's a better way - and maybe a tutorial (or help thing i should use in VB) for this... [edited by - Wizzy on October 13, 2003 11:42:51 AM] [edited by - Wizzy on October 13, 2003 11:43:38 AM] [edited by - Wizzy on October 13, 2003 11:44:12 AM]

Share this post


Link to post
Share on other sites
You can include quotes in strings, but you have to do it a bit different than normal characters. In languages like c you use an escape character.

printf("This shows how to use \" in string constants in c/c++");

But I don''t think you can use an escape character in VB.

IIRC the easiest way to do it in VB is to do:

print #1, "This shows how to use " + chr(34) + "''s in your string constants."

It''s been a while since I''ve done VB so I can''t promise you I did that exactly right

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can just us 2 double-quotes, and it will insert a single double-quote, instead of ending the string. So
<code>print #1, "This has a double-quote ("" in it."</code>
would result in
<code>This has a double-quote (" in it.</code>
being inserted into the file.

Share this post


Link to post
Share on other sites
quote:
Original post by Drakonite
You can include quotes in strings, but you have to do it a bit different than normal characters. In languages like c you use an escape character.

printf("This shows how to use \" in string constants in c/c++");

But I don''t think you can use an escape character in VB.

IIRC the easiest way to do it in VB is to do:

print #1, "This shows how to use " + chr(34) + "''s in your string constants."

It''s been a while since I''ve done VB so I can''t promise you I did that exactly right


almost change + for & and it will work :D

anytime you want to insert special chars in use this method.

instead of looking up what the codes are from somewhere you can use the asc(") which will return the number of the char you want.

chr(34) is the best way to go!

Share this post


Link to post
Share on other sites
+ works just as well as & for string concatenation in VB (maybe there is a difference, but i never found any and i used it professionally for years)...

also, i made the double quotes a constant string so i could code like so:

someStringVar = "Hello, here comes a double quote " + quoteConstant + ", wasn''t that nice!"


actually, there might be a built-in constant (vbQuote or some such)...

the only reason i mention that is because it makes it easier to see what is going on if you look at the code a year later (as opposed to "hmm... what the hell is chr$(34)? lemme look it up!")...

Share this post


Link to post
Share on other sites
But, what's wrong with just using:
Print("and so, he was all, ""yeah""")

--
Hi!

Ryan Patterson - http://www14.brinkster.com/rpatters/temp/downloads.html

[edited by - cgamesplay on October 13, 2003 10:05:36 PM]

Share this post


Link to post
Share on other sites