Microsoft Visual Basic Scripting Edition

The Welcome Sample

How it works

How does the Welcome Sample work? As the page is loaded, script tags are encountered by the browser. Script tags may contain code that executes as the HTML page is being parsed. This code may write content into the page using an object supplied by the browser. To do this, the VBScript code calls the "Document" object's "Write" method, passing a string. All of this is done on the client side: no special server side processing, no PERL hacking, no fuss, no muss!

The code


<SCRIPT LANGUAGE="VBScript">
	' This line executes when the script tag is parsed.
	Call PrintWelcome

	Sub PrintWelcome
		Dim h

		h = Hour(Now)
		If h < 12 then 
			Document.Write "Good morning!  "
		ElseIf h < 17 then 
			Document.Write "Good afternoon!  "
		Else 
			Document.Write "Good evening!  "
		End If
		Document.Write "Welcome to the world of VBScript.  "
		Document.Write "Just in case you were wondering, it's "
		Document.Write Time() & " on " & Date() & "."
	End Sub
</SCRIPT>