|
-
Jan 12th, 2006, 01:06 PM
#1
Thread Starter
Hyperactive Member
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.
-
Jan 12th, 2006, 01:32 PM
#2
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:
Option Explicit
Private Sub Command1_Click()
Dim strArr() As String
Dim i As Integer
Dim intFile As Integer
Dim strText As String
intFile = FreeFile()
Open App.Path & "\words.txt" For Input As #intFile
strArr = Split(Input$(LOF(intFile), intFile), vbNewLine)
Close #intFile
Open App.Path & "\stuff.txt" For Input As #intFile
strText = Input$(LOF(intFile), intFile)
Close #intFile
For i = LBound(strArr) To UBound(strArr)
Open App.Path & "\" & strArr(i) & ".html" For Output As #intFile
Print #intFile, strText
Close #intFile
Next i
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.
-
Jan 14th, 2006, 05:09 PM
#3
Thread Starter
Hyperactive Member
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.
-
Jan 14th, 2006, 05:20 PM
#4
Re: Making HTML files.
VB Code:
For i = LBound(strArr) To UBound(strArr)
Open App.Path & "\" & strArr(i) & ".html" For Output As #intFile
[COLOR=Sienna]strText = Replace(strText, "Wild Card", strArr(i))[/COLOR]
Print #intFile, strText
Close #intFile
Next i
-
Jan 14th, 2006, 05:25 PM
#5
Thread Starter
Hyperactive Member
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 ?
-
Jan 14th, 2006, 05:57 PM
#6
Thread Starter
Hyperactive Member
Re: Making HTML files.
im having trouble getting it to do both at the same time
-
Jan 14th, 2006, 07:16 PM
#7
Re: Making HTML files.
i made a slight mistake , added or modified the coloured lines,
VB Code:
Option Explicit
Private Sub Command1_Click()
Dim strArr() As String
Dim i As Integer
Dim intFile As Integer
Dim strText As String
[COLOR=DarkRed]Dim strTxtOld As String[/COLOR]
intFile = FreeFile()
Open App.Path & "\words.txt" For Input As #intFile
strArr = Split(Input$(LOF(intFile), intFile), vbNewLine)
Close #intFile
Open App.Path & "\stuff.txt" For Input As #intFile
strText = Input$(LOF(intFile), intFile)
Close #intFile
[COLOR=DarkRed]strTxtOld = strText[/COLOR]
For i = LBound(strArr) To UBound(strArr)
Open App.Path & "\" & strArr(i) & ".html" For Output As #intFile
[COLOR=DarkRed]strText = Replace(strTxtOld, "Wild Card", strArr(i))
Doevents[/COLOR]
Print #intFile, strText
Close #intFile
Next i
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|