Professional Documents
Culture Documents
Vbscript Basics Tutorial5
Vbscript Basics Tutorial5
1. It is a scripting language
7. Conditional Statements
x=4
if x=4 then
document.write(x)
elseif x=5 then
document.write(“x=5”)
else
document.write(“x=6”)
end if
8.for loops
for a=1 to 3
document.write("<br>"&a)
next
for a=1 to 3 step 2
document.write("<br>"&a)
next
for a=3 to 1 step -2
document.write("<br>"&a)
next
dim names(1)
names(0)="abcd"
names(1)="bcde"
for each i in names
document.write("<br>"&i)
10.Array Creation
dim names[1]
names[0]=”abcd”
names[1]=”bcde”
for i=0 to 1
document.write(“<br>”,&i)
1. document.write(date())-----------------------------------------6/25/2009
2. document.write(time())-----------------------------------------10:19:58 AM
3. document.write(WeekDayName(1))----- --------------------Sunday
4. document.write(WeekDayName(1,true))---------------------Sun
5. document.write(WeekdayName(weekday(date)))----------- Thursday
6. document.write(MonthName (month(date)))----------------- June
7. document.write(IsDate("10/30/99"))--------------------------- True
8. document.write(ucase("abcd"))---------------------------------ABCD
9. document.write(Lcase("ABCD"))------------------------------abcd
10. document.write(strReverse("ABCD"))------------------------DCBA
11. document.write(Round(48.66776677))------------------------49
12. document.write(Round(48.36776677))------------------------48
13.document.write(now())------------------------------------------6/25/2009 11:50:27 AM
14. document.write(Hex(460))-------------------------------------1CC
15. document.write(SQR(16))--------------------------------------4
16. document.write(len("india"))-----------------------------------5
17. x=Array(12,13,14,15,16)
document.write(x(3))-------------------------------------------15
18. randomize()
randomNumber=Int(100 * rnd())
document.write("A random number: <b>" & randomNumber & "</b>").
Ex: A random number: 56 ---First Run
A random number: 78 ---Second Run
<html>
<head>
<script type="text/vbscript">
<!--
'How to declare variables and print them
a=8
name="hari"
document.write("The value of a is : " &a&"<br>The name is : " &name)
-->
</script>
</body>
</html>
Output :
The value of a is : 8
The name is : hari
myfunction is called
myfunction is called
y is bigger than x and z
i valus is 2 :
First for loop
1
2
3
Second for loop
1
3
Third for loop
3
1
Using for each
abcd
bcde
Using do while loops
1
2
1
2
This is sub procedure
Function returns the value : 12
Today's date is : 6/25/2009
Now the time is : 3:07:28 PM
The weekday 1 represents : Sunday
The weekday 1 shortform represents : Sun
Today is : Thursday
This month is : June
Date format is true or false : True
Converting the letters to uppercase : ABCD
Converting the letters to lowercase : abcd
Reverse the string: DCBA
Round the number to nearer value: 49
Round the number to nearer value: 48
The date and time is : 6/25/2009 3:07:28 PM
square root value of 16 is : 4
The length of string usa is : 3
The value at the 4th position in the array x is : 15
A random number: 8