Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




3 posts

Wannabe Geek


#153914 12-Oct-2014 19:19
Send private message

I am trying to use windows VBScript to write a webpage. I have another Windows VBScript file that creates a user on my website, but now I want a Windows VBScript file that will write the template for the webpage so it is a lot easier for me. After editing it, I opened it and it gave the following message: 

 Error

Please look over the code below and find the problem.
The code I used is:


Option Explicit
Dim filename, Title, h1
Dim fs, f
While NOT IsAlphaNumeric(filename)
If filename <> "" AND NOT IsAlphaNumeric(filename) Then
MsgBox "FileName must be alphanumeric, without spaces!",16,"PageCreator"
End If
filename = InputBox("Enter FileName (without file extenison):","PageCreator")
Wend


While NOT IsAlphaNumeric(Title)
If Title <> "" AND NOT IsAlphaNumeric(Title) Then
MsgBox "Title must be alphanumeric, without spaces!",16,"PageCreator"
End If

Wend
While NOT IsAlphaNumeric(h1)
If filename <> "" AND NOT IsAlphaNumeric(h1) Then
MsgBox "Heading must be alphanumeric, without spaces!",16,"PageCreator"
End If
h1 = InputBox("Enter Heading to appear on page:","PageCreator")
Wend
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(Trim(filename) & ".html",2,True)
f.WriteLine("<!DOCTYPE html>
<html>
<head>")
f.Write("<title>""" & Title & """</title>
<link rel="shortcut icon" href="favicon.png">
<link href="Site.css" rel="stylesheet"></head>
<body>
<nav id="nav01"></nav>
<div id="main">
<h1>""" & Heading & """</h1>
<footer id="foot01"></footer>
</div>
<script src="Script.js"></script>
</body>
</html>;")
Set f = Nothing
Set fs = Nothing
MsgBox "Password file created!"

Function IsAlphaNumeric(str)
Dim ianRegEx
Set ianRegEx = New RegExp
ianRegEx.Pattern = "^[a-zA-Z0-9]+$"
ianRegEx.Global = True
IsAlphaNumeric = ianRegEx.Test(str)
End Function

Create new topic
BDFL - Memuneh
67785 posts

Uber Geek

Administrator
Trusted
Geekzone
Lifetime subscriber

  #1152342 12-Oct-2014 19:31
Send private message

You're missing the inputbox for the title.

Are those f.Write split into multiple line? If yes, have you added "_" to the end of the lines to signify a split line?


f.WriteLine("<!DOCTYPE html>
<html>
<head>")


should really be something like 

f.WriteLine("<!DOCTYPE html>" & _ 
"<html>" & _
"<head>")

And the output will all be in a single line since there's not VBCRLF in there.





 

 

These links are referral codes

 

Geekzone broadband switch | Eletricity comparison and switch | Hatch investment (NZ$ 10 bonus if NZ$100 deposited within 30 days) | Sharesies | Mighty Ape | Backblaze | Amazon | My technology disclosure 




3 posts

Wannabe Geek


  #1153715 14-Oct-2014 15:54
Send private message

freitasm: You're missing the inputbox for the title.

Are those f.Write split into multiple line? If yes, have you added "_" to the end of the lines to signify a split line?


f.WriteLine("<!DOCTYPE html>
<html>
<head>")


should really be something like 

f.WriteLine("<!DOCTYPE html>" & _ 
"<html>" & _
"<head>")

And the output will all be in a single line since there's not VBCRLF in there.



Now it gives the following error:





 
 
 
 


171 posts

Master Geek


  #1159884 22-Oct-2014 11:42
Send private message

While it may look pretty to have all those tags on separate lines, you can just write out a bunch of them on one line, for example:
"<html><head><title>the title</title></head><body>"  can all be on one line.  This will make your scripting a little easier.




3 posts

Wannabe Geek


#1160165 22-Oct-2014 17:32
Send private message

Now it shows this error when trying to execute the .vbs file



HELP

8035 posts

Uber Geek

Trusted

  #1160174 22-Oct-2014 17:48
Send private message

What's the overall thing you are trying to achieve? 

The reason I ask is because writing an actual html file/page per user is arse backwards when you could write a user row/record to a database and use a server side language like asp.net, php or ruby to have a dynamic database driven page/app.

Create new topic




News »

Freeview On Demand app launches on Sony Android TVs
Posted 6-Aug-2020 13:35


UFB hits more than one million connections
Posted 6-Aug-2020 09:42


D-Link A/NZ extends COVR Wi-Fi EasyMesh System series with new three-pack
Posted 4-Aug-2020 15:01


New Zealand software Rfider tracks coffee from Colombia all the way to New Zealand businesses
Posted 3-Aug-2020 10:35


Logitech G launches Pro X Wireless gaming headset
Posted 3-Aug-2020 10:21


Sony Alpha 7S III provides supreme imaging performance
Posted 3-Aug-2020 10:11


Sony introduces first CFexpress Type A memory card
Posted 3-Aug-2020 10:05


Marsello acquires Goody consolidating online and in-store marketing position
Posted 30-Jul-2020 16:26


Fonterra first major customer for Microsoft's New Zealand datacentre
Posted 30-Jul-2020 08:07


Everything we learnt at the IBM Cloud Forum 2020
Posted 29-Jul-2020 14:45


Dropbox launches native HelloSign workflow and data residency in Australia
Posted 29-Jul-2020 12:48


Spark launches 5G in Palmerston North
Posted 29-Jul-2020 09:50


Lenovo brings speed and smarter features to new 5G mobile gaming phone
Posted 28-Jul-2020 22:00


Withings raises $60 million to enable bridge between patients and healthcare
Posted 28-Jul-2020 21:51


QNAP integrates Catalyst Cloud Object Storage into Hybrid Backup solution
Posted 28-Jul-2020 21:40



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.