Results 1 to 7 of 7

Thread: Making HTML files.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Making HTML files.

    Ok my mate is in the process of making a new site. And he has a list of 500+ words that he has to make a page for.

    So he would load a list of words, and then it would make a file called

    word.html
    word1.html
    word2.html

    is this possible within VB ?

    Part 2 of request

    Ok if that is possible, would be possible to have some default code in each file aswell.

    Code:
    <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns="http://www.w3.org/TR/REC-html40">
    <head>
    <link rel="stylesheet" href="style.css" type="text/css">
    <title>IntelliGambler.com</title>
    </head>
    <body>
    <center>
    	<table width="650" height="500" bgcolor="#EEEEEE">
    	<tr>
    	<td valign="top">
    			<table border="0" cellpadding="0" cellspacing="0" class="outline" width="645" align="center">
                <tr>
                  <td valign="center" align="center" background="images/mainhead.jpg" width="600" height="34">
    				<p align="center"><b>
    				<font face="Papyrus" size="3" color="#FFFFFF">Wild Card</font></b></td>
                </tr>
                <tr>
                  <td class="right_content">
                  <p align="left">A card, such as a joker or a designated
    				rank, that can be assigned any rank and suit.<p align="left"><a href="javascript:history.go(-1)">Back 
    				to Glossary</a></td>
                </tr>
                            </table></td></tr></table>
              </center>
    </body>
    </html>

    so i would end up with a html file for each of the words with that code in them.

    Hope this is clear.
    Im Learning !!!!

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Making HTML files.

    if i got you right and the words are in a text file in the form

    word1
    word2
    word3

    ....

    then you could say,


    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  
    5. Dim strArr() As String
    6. Dim i As Integer
    7. Dim intFile As Integer
    8. Dim strText As String
    9.  
    10.     intFile = FreeFile()
    11.    
    12.     Open App.Path & "\words.txt" For Input As #intFile
    13.       strArr = Split(Input$(LOF(intFile), intFile), vbNewLine)
    14.     Close #intFile
    15.    
    16.     Open App.Path & "\stuff.txt" For Input As #intFile
    17.      strText = Input$(LOF(intFile), intFile)
    18.     Close #intFile
    19.    
    20.     For i = LBound(strArr) To UBound(strArr)
    21.         Open App.Path & "\" & strArr(i) & ".html" For Output As #intFile
    22.         Print #intFile, strText
    23.         Close #intFile
    24.     Next i
    25.  
    26. End Sub

    for stuff.txt just paste your page code into notepad and save as stuff.txt. both text files need to be in the same folder as the project so you'd need to save the project first somewhere.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Making HTML files.

    Ok i have all this working now, but i want to be able to edit one line of stuff.txt each time it makes a new html file.
    The line is

    <font face="Papyrus" size="3" color="#FFFFFF">Wild Card</font></b></td>

    and its on line 15 on the text file if that makes anything easier. Where it says wild card i want it to be the word that its upto in the list of words.txt.

    Hope this is clear.
    Im Learning !!!!

  4. #4
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Making HTML files.

    VB Code:
    1. For i = LBound(strArr) To UBound(strArr)
    2.         Open App.Path & "\" & strArr(i) & ".html" For Output As #intFile
    3.        
    4.         [COLOR=Sienna]strText = Replace(strText, "Wild Card", strArr(i))[/COLOR]
    5.        
    6.         Print #intFile, strText
    7.         Close #intFile
    8.     Next i

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Making HTML files.

    i need the program to stil do the same thing as before, aswell as changing this line. Wil this do that ?
    Im Learning !!!!

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Posts
    300

    Re: Making HTML files.

    im having trouble getting it to do both at the same time
    Im Learning !!!!

  7. #7
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Making HTML files.

    i made a slight mistake , added or modified the coloured lines,

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.  
    5. Dim strArr() As String
    6. Dim i As Integer
    7. Dim intFile As Integer
    8. Dim strText As String
    9.  
    10. [COLOR=DarkRed]Dim strTxtOld As String[/COLOR]
    11.  
    12.     intFile = FreeFile()
    13.    
    14.     Open App.Path & "\words.txt" For Input As #intFile
    15.       strArr = Split(Input$(LOF(intFile), intFile), vbNewLine)
    16.     Close #intFile
    17.    
    18.     Open App.Path & "\stuff.txt" For Input As #intFile
    19.      strText = Input$(LOF(intFile), intFile)
    20.     Close #intFile
    21.    
    22.     [COLOR=DarkRed]strTxtOld = strText[/COLOR]
    23.    
    24.     For i = LBound(strArr) To UBound(strArr)
    25.         Open App.Path & "\" & strArr(i) & ".html" For Output As #intFile
    26.        
    27.         [COLOR=DarkRed]strText = Replace(strTxtOld, "Wild Card", strArr(i))
    28.         Doevents[/COLOR]
    29.  
    30.         Print #intFile, strText
    31.         Close #intFile
    32.        
    33.     Next i
    34.  
    35. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width