Write 'Hello World' with your First ASP Script

First lets use a text editor such as Notepad to write this script. Go to Start > Programs > Accessories > Notepad and copy the code in blue and the comments in green and paste them into notepad. Remember that anything after the ' is commented out and thus not processed.

<%@ Language="VBscript" %>

<% Dim I     ' declare a variable I which will act as our loop counter variable
' Start the loop which will loop from 1 to 5 incrementing I by one each time
For I = 1 To 5 ' FONT TAG's SIZE attribute will be determined by the value of I
' so on the first loop the font tag's size will be 1 and on the last loop it will be 5.
%>

<font size="<% response.write(I) %>">Hello World</font>
<br>
<%
Next       ' repeat the loop again only if it hasn't passed through 5 yet.
%>

To test this script on your own computer you should remember than when you installed PWS or IIS an 'Inetpub' folder should have been created on your harddrive with the sub folder 'wwwroot'. Locate this folder ie 'wwwroot' and inside it create a new folder called 'ASP'.

Save the file as Helloworld.asp in your C:\inetpub\wwwroot\ASP folder (you may need to change the drive letter if Inetpub is not on your C drive). Next open your browser and type http://localhost/asp/helloworld.asp in the address/url box and hit enter. You should see the output below provided you have PWS or IIS installed correctly.

ASP first script


If you are not running the script on your own local computer but on your hosting company's web space then just simply save the file, upload and run the script.

Related Tutorial 'Looping' (The For Next loop explained in more detail)
Related Tutorial 'Installing ASP on your own computer'

Advertisements



MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.

Get your best asp web hosting provider now and save 25%