Está en la página 1de 7

VBSCRIPT PROGRAMS

1. FIRST PAGE
<html>
<body>
<%response.write("This is my first VBScript!")%>
</body>
</html>
2.PRINT A TEXT WITH TAG
<html>
<body>
<%
response.write("<h1>Hello World!</h1>")
%>
</body>
</html>
3. CREATING A VARIABLE
<html>
<body>
<%
Dim firstname
firstname="Hege"
response.write(firstname)
response.write("<br>")
firstname="Tove"
response.write(firstname)
%>
<p>The script above declares a variable, assigns a value to it, and displays the value. Then, it
changes the value, and displays the value again.</p>
</body>
</html>
4. INSERT A VALUE TO VARIABLE
<html>
<body>
<%

Dim name
name="Jan Egil"
response.write("My name is: " & name)
%>
</body>
</html>
5. CREATE AN ARRAY
<html>
<body>
<%
Dim famname(5)
famname(0)="Jan Egil"
famname(1)="Tove"
famname(2)="Hege"
famname(3)="Stale"
famname(4)="Kai Jim"
famname(5)="Borge"
For i=0 To 5
response.write(famname(i) & "<br>")
Next
%>
</body>
</html>
6.SUB PROCEDURE
<html>
<body>
<%
Sub mysub()
response.write("I was written by a sub procedure")
End Sub
response.write("I was written by the script<br>")
Call mysub()
%>
</body>
</html>

7. FUNCTION PROCEDURE
<html>
<body>
<%
Function myfunction()
myfunction=Date()
End Function
response.write("Today's date: ")
response.write(myfunction())
%>
<p>A Function procedure can return a result.</p>
</body>
</html>
8. FUNCTION
<html>
<body>
<%
Function myfunction(a,b)
myfunction=a+b
End Function
response.write(myfunction(5,9))
%>
</body>
</html>
9. IF THEN ELSE
<html>
<body>
<%
i=hour(time)
If i < 10 Then
response.write("Good morning!")
Else
response.write("Have a nice day!")
End If
%>
</body>
</html>

10. IF THEN ELSE IF


<html>
<body>
<%
i=hour(time)
If i = 10 Then
response.write("Just started...!")
ElseIf i = 11 Then
response.write("Hungry!")
ElseIf i = 12 Then
response.write("Ah, lunch-time!")
ElseIf i = 16 Then
response.write("Time to go home!")
Else
response.write("Unknown")
End If
%>
</body>
</html>
11. DATE AND TIME
<html>
<body>
<%
response.write("Today's date is " & Date())
response.write("<br>")
response.write("The time is " & Time())
%>
</body>
</html>
12. WEEKDAY NAME AND MONTH
<html>
<body>
<%
response.write("Today's day is " & WeekdayName(Weekday(Date)))
response.write("<br>")
response.write("The month is " & MonthName(Month(Date)))
%>

</body>
</html>
13. UPPER CASE AND LOWER CASE
<html>
<body>
<%
txt="Have a nice day!"
response.write(UCase(txt))
response.write("<br>")
response.write(LCase(txt))
%>
</body>
</html>
14. REMOVING LEADING AND TRAILING SPACES
<html>
<body>
<%
fname=" Bill "
response.write("Hello" & Trim(fname) & "Gates<br>")
response.write("Hello" & RTrim(fname) & "Gates<br>")
response.write("Hello" & LTrim(fname) & "Gates<br>")
%>
</body>
</html>
15. REVERSE A STRING
<html>
<body>
<%
sometext = "Hello Everyone!"
response.write(StrReverse(sometext))
%>
</body>
</html>
16. ROUND A NUMBER
<html>
<body>

<%
i = 48.66776677
j = 48.3333333
response.write(Round(i))
response.write("<br>")
response.write(Round(j))
%>
</body>
</html>
17. REPLACE SOME TEXT WITHIN A STRING
<html>
<body>
<%
sometext="Welcome to this Web!!"
response.write(Replace(sometext, "Web", "Page"))
%>
</body>
</html>
.
ASP
How to Install IIS on Windows 7 and Windows Vista
Follow these steps to install IIS:
1. Open the Control Panel from the Start menu
2. Double-click Programs and Features
3. Click "Turn Windows features on or off" (a link to the left)
4. Select the check box for Internet Information Services (IIS), and click OK
After you have installed IIS, make sure you install all patches for bugs and security problems.
(Run Windows Update).
How to Install IIS on Windows XP and Windows 2000
Follow these steps to install IIS:
1. On the Start menu, click Settings and select Control Panel
2. Double-click Add or Remove Programs
3. Click Add/Remove Windows Components
4. Click Internet Information Services (IIS)
5. Click Details
6. Select the check box for World Wide Web Service, and click OK
7. In Windows Component selection, click Next to install IIS

After you have installed IIS, make sure you install all patches for bugs and security problems.
(Run Windows Update).
Test Your Web
After you have installed IIS or PWS follow these steps:
1. Look for a new folder called Inetpub on your hard drive
2. Open the Inetpub folder, and find a folder named wwwroot
3. Create a new folder, like "MyWeb", under wwwroot
4. Write some ASP code and save the file as "test1.asp" in the new folder
5. Make sure your Web server is running (see below)
6. Open your browser and type "http://localhost/MyWeb/test1.asp", to view your first web
page

También podría gustarte