Getting Your Hands Dirty With VBScript
by Amrit HallanThursday, 18th August 2005
First thing first: HTML tags and ASP scripts don't socialize well, and although it is not a politically correct agenda, you have to segregate them. Whenever you are writing the VBScript code for ASP, enclose the code within <% %>.
So if you want to initialize a VBScript variable, do it like this:
<%
Dim name
name = "Tutan Khamen"
%>
For instance, if you want to use the variable "name" in your HTML (ASP, actually) page, all you have to do is:
<%@Language=VBScript%>
<% Option Explicit %>
<html>
<head>
<title>Testing a VBSCript</title>
</head> <body> <% Dim name name = "Tutan Khamen"
%>
<p><%=name%>! An ancient Egyptian mummy!</p>
</body>
</html>
Another example:
<%@Language=VBScript%>
<% Option Explicit %>
<html>
<head>
<title>Testing a VBSCript</title>
</head>
<body>
<%
Dim number1, number2
number1 = 33
number2 = 44
%>
<p>The product of <%=number1%> and <%=number2%> is <%=number1 * number2%></p>
</body>
</html>
So now its amply clear that whenever you want to insert Server Side code, or a part of it, you enclose it within <% %>.
You can try making short programs and test run the page.
Amrit Hallan is a freelance web designer. For all web site development and web promotion needs, you can get in touch with him at amrit@bytesworth.com . For further details, visit http://www.bytesworth.com You can subscribe to his newsletter [BYTESWORTH REACHOUT] on Web Designing Tips & Tricks by sending a blank email at bytesworth-subscribe@topica.com.