4. 4
PROGRAM 3
1. <html>
2. <head>
3. <title> </title>
4. <script language="vbscript">
5. sub button1_onclick
6. dim localtime,localhour
7. localtime=now
8. localhour=hour(localtime)
9. if localhour<12 then
10. document.write("good morning")
11. else
12. document.write("good day")
13. end if
14. end sub
15. </script>
16. </head>
17. <body>
18. <form name="form1">
19. <input type="button" name="button1" value="click">
20. </form>
21. </body>
22. </html>
5. 5
PROGRAM 4
1. <html>
2. <head>
3. <title>input box</title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim username
8. username=inputbox("please enter your name","user name")
9. document.write("welcome "& username &" i hope you will
enjoy learning")
10.</script>
11.</body>
12.</html>
6. 6
PROGRAM 5
1. <html>
2. <head>
3. <title>message box</title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim username, salary, hours
8. username=inputbox("please enter your name","user name")
9. hours=inputbox("enter the numbers of hours", "working
hours")
10. salary = hours*5 + 100
11. call msgbox("your salary is" & salary,5, username)
12. </script>
13. </body>
14. </html>
7. 7
PROGRAM 6
1. <html>
2. <head>
3. <title></title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim bt
8. bt=msgbox("press a button of the following",3,"press a
button")
9. if bt=6 then msgbox"you pressed yes",0,"result"
10. if bt=7 then msgbox"you pressed no",0,"result"
11. if bt=2 then msgbox"you pressed cancel",0,"result"
12. </script>
13. </body>
14. </html>
8. 8
PROGRAM 7
1. <html>
2. <head>
3. <title>do while..loop </title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim age
8. age=inputbox("enter your age","age")
9. do while age<=0 or age>100
10.age=inputbox("please enter a valid value for age (0-
100)","age")
11.loop
12.msgbox "thanks for providing your age." & age
13.</script>
14.</body>
15.</html>
9. 9
PROGRAM 8
1. <html>
2. <head>
3. <title>do until..loop </title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim age
8. age=inputbox("enter your age","age")
9. do until age>0 and age<=100
10. age=inputbox("please enter a valid value for age (0-
100)","age")
11. loop
12. msgbox "thanks for providing your age." & age
13. </script>
14. </body>
15. </html>
10. 10
PROGRAM 9
1. <html>
2. <head>
3. <title>do loop while.. </title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim age
8. do
9. age=inputbox("please enter a valid value for age (0-
100)","age")
10.loop while age<=0 or age>100
11.msgbox "thanks for providing your age." & age
12.</script>
13.</body>
14.</html>
11. 11
PROGRAM 10
1. <html>
2. <head>
3. <title>do loop until.. </title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim age
8. do
9. age=inputbox("please enter a valid value for age (0-
100)","age")
10.loop until age>0 and age<=100
11.msgbox "thanks for providing your age." & age
12.</script>
13.</body>
14.</html>
12. 12
PROGRAM 11
1. <html>
2. <head>
3. <title>for.. to.. step.. next.. </title>
4. </head>
5. <body>
6. <script language="vbscript">
7. dim sum,i
8. sum=0
9. for i=1 to 10 step 1
10.sum=sum+i
11.next
12.document.write("the sum is " & sum& "<br/>")
13.msgbox "the sum of 1.....10 is " & sum
14.</script>
15.</body>
16.</html>
13. 13
PROGRAM 12
1. <html>
2. <head>
3. <title>(1) </title>
4. </head>
5. <body>
6. <script language="vbscript">
7. familyname=array("ali","muna","suha","maha","heba"
,"jone")
8. for i=0 to 5
9. document.write(familyname(i) & "<br/>")
10. next
11. </script>
12. </body>
13. </html>
14. 14
PROGRAM 13
1. <html>
2. <head>
3. <title>2))</title>
4. </head>
5. <body>
6. <script language="vbscript">
7. familyname=array("ali","muna","suha","maha","heba",
"jone")
8. for each x in familyname
9. document.write(x & "<br/>")
10. next
11. </script>
12. </body>
13. </html>
15. 15
PROGRAM 14
1. <html>
2. <head>
3. <title>3)) </title>
4. </head>
5. <body>
6. <p>
7. </p>
8. <script language="vbscript">
9. option explicit
10. dim i,n
11. dim names()
12. n=int(inputbox("enter the number of names","number of names"))
13. redim names(n)
14. for i=0 to n-1
15. names(i)=inputbox("enter a name","names")
16. next
17. for i=n-1 to 0 step -1
18. document.write( names(i) & "<br>")
19. next
20. </script>
21. </body>
22. </html>
16. 16
PROGRAM 15
1. <html>
2. <head>
3. <title> 1)) </title>
4. <script language="vbscript">
5. sub myaverage()
6. a=cint(inputbox("please enter a number","average"))
7. b=cint(inputbox("please enter a number","average"))
8. c=cint(inputbox("please enter a number","average"))
9. av=(a+b+c)/3
10. msgbox "the average is " & av
11. end sub
12. </script>
13. </head>
14. <body>
15. <form>
16. <input type="button" value="calculate average" onclick="call
myaverage()">
17. </form>
18. </body>
19. </html>
17. 17
PROGRAM 16
1. <html>
2. <head>
3. <title> </title>
4. <script language="vbscript">
5. function average(x,y,z)
6. average=(x+y+z)/3
7. end function
8. sub myaverage()
9. a=cint(inputbox("please enter a number","average"))
10. b=cint(inputbox("please enter a number","average"))
11. c=cint(inputbox("please enter a number","average"))
12. av=average(a,b,c)
13. msgbox "the average is " & av
14. end sub
15. </script>
16. </head>
17. <body>
18. <form>
19. <input type="button" value="calculate average" onclick="call
myaverage()">
20. </form>
21. </body>
22. </html>
18. 18
PROGRAM 17
<html>
<head>
<title></title>
</head>
<body>
<p>finding the max of three numbers</p>
<script type="text/vbscript">
option explicit
dim x,y,z,max
x=int(inputbox("enter the first number", "numbers"))
y=int(inputbox("enter the first number", "numbers"))
z=int(inputbox("enter the first number", "numbers"))
if x>y then
max=x
else
max=y
end if
if z>max then
max=z
end if
call msgbox("the max is " &max,0,"maximum")
</script>
</form>
</body>
</html>