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

Started by
5 comments, last by Wizzy 20 years, 6 months ago
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]
Advertisement
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
Shoot Pixels Not People
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.
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!

+ 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!")...
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
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]
-- Hi!Ryan Patterson - <a href="http://cgamesplay.allegronetwork.com>http://cgamesplay.allegronetwork.com
i never heard of that double-double-quote thing before... but if it works, rock on!
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])

This topic is closed to new replies.

Advertisement