Friday, 31 October 2014

vb script practicle tutorial


VBScript
v  VBScript is a Microsoft scripting language.
v  VBScript is the default scripting language in ASP.
v  Client-side VBScript only works in Internet Explorer!!!
<html>
<body>

<script type="text/vbscript">
document.write("This is my first VBScript!")
</script>

</body>
</html>
<html>
<body>

<script type="text/vbscript">
document.write("<font color=green size=7>Hello World!</font>")
</script>

</body>
</html>

<html>
<head>
<script type="text/vbscript">
function choksi()
alert("Hello World!")
end function
</script>
</head>

<body onload="choksi()">

<p>We usually use the head section for functions 
(to be sure that the functions are loaded before they are called).</p>

</body>
</html>




<html>
<head>
<script type="text/vbscript">
function choksi()
document.write("Hello World!")
end function
</script>
</head>

<body>
<input type="button" value="click here" onclick="choksi()">
<p>We usually use the head section for functions 
(to be sure that the functions are loaded before they are called).</p>

</body>
</html>

Program-5  Create A Variable
<html>
<body>
<script type="text/vbscript">
Dim firstname
Dim lastname
firstname="ahmad"
lastname="choksi"
document.write(firstname)
document.write("<br>")
document.write(lastname)
</script>

<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>

<body>
<script type="text/vbscript">
Dim name,surname
name="ahmad"
surname="choksi"
document.write("My name is: " & name &"<br>")
document.write("My surname is: " & surname)
</script>
</body>
</html>
Program-7  Create an array
<html>
<body>

<script type="text/vbscript">
Dim famname(5)
famname(0)="Jan Egil"
famname(1)="Tove"
famname(2)="Hege"
famname(3)="Stale"
famname(4)="Kai Jim"
famname(5)="Borge"
document.write(famname(5))
</script>
</body>
</html>
Program-7  Create an array
<html>
<body>
<script type="text/vbscript">
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
  document.write(famname(i) & "<br />")
Next
</script>
</body>
</html>
Program-8  Sub procedure
<html>
<head>
<script type="text/vbscript">
Sub mySub()
  msgbox("This is a Sub procedure")
End Sub
</script>
</head>
<body>
<script type="text/vbscript">
Call mySub()
</script>
<p>A Sub procedure does not return a result.</p>
</body>
</html>
Program-9  Function procedure
<html>
<head>
<script type="text/vbscript">
Function myFunction()
 myFunction = "BLUE"
End Function
</script>
</head>
<body>
<script type="text/vbscript">
document.write("My favorite color is " & myFunction())
</script>
<p>A Function procedure can return a result.</p>
</body>
</html>

No comments:

Post a Comment