Ideas To Implement and Execute

What on earth would you want to read this blog for? After all, can’t you just search information in Internet. Well, unfortunately, it’s not that simple. So, this blog is for those users who need the exact information in short and simple format.

VBScript Programs with Examples

Fibonacci Series VBScript Program (for beginners)
This time around I want to show how to write simple program to generate Fibonacci Series in VBScript using Do While Loop, For Loop and While Loop with example.

Note:
  • No semicolon is used at the end of a statement in VBScript
  • Only very few browser (Internet Explorer) supports VBScript
Do While Loop (fibonacci series program in VBScript)
<html>
<body>
<h2><center>
<script type="text/vbscript">
dim a,b,c
a=0
b=1
do while c<=21
document.write(b&"<br/>")
c=a+b
a=b
b=c
loop
</script>
</center></h2>
</body>
</html>

For Loop (fibonacci series program in VBScript)
<html>
<body><center>
<script type="text/vbscript">
dim a,b,c,i
a=0
b=1
for i=1 to 100
c=a+b
document.write(b&"<br/>")
a=b
b=c
next
</script>
</center>
</body>
</html>

While Loop (fibonacci series program in VBScript)

<html>
<body><center>
<script type="text/vbscript">
dim a,b,c
a=0
b=1
while c<21
document.write(b&"<br/>")
c=a+b
a=b
b=c
wend
</script>
</center>
</body>
</html>


Display Array Element (for beginners)
This is a Simple VBScript Program for Beginners to display array element.

<html>
<head>
</head>
<body><h2><p align="center">For each statement to show every elements in an array.<p></h2>
<center><h3>
<script type="text/vbscript">
dim name(4)
name(0)="Apple"
name(1)="Orange"
name(2)="Bread"
name(3)="Grapes"
name(4)="Pizza"
for each eatables in name
document.write(eatables)
document.write("<br/>")
next
</script>
</body>
</html>

Generate Days VBScript Program (for beginners)
This is a Simple VBScript Program for Beginners to generate days.

<html>
<body><center><h1>
<script type="text/vbscript">
d=weekday(Date)
select case d
  case 1
    document.write("Sleepy Sunday")
  case 2
    document.write("Monday again!")
  case 3
    document.write("Just Tuesday!")
  case 4
    document.write("Wednesday!")
  case 5
    document.write("Thursday...")
  case 6
    document.write("Finally Friday!")
  case Else
    document.write("Super Saturday!!!!")
End Select
</script>
</h1>
</center>
</body>
</html>

Generate Date and Time VBScript Program (for beginners)
This is a Simple VBScript Program for Beginners to generate Date and Time in different format.

<html>
<body>
<center>
<script type="text/vbscript">
d=CDate("October 22, 2010")
document.write(d&"<br/>")
document.write("Current system date is:"&date&"<br/>")
document.write("Current system time is:"&time&"<br/>")
document.write(DatePart("m",Now())&"<br/>")
document.write(DateAdd("yyyy",1,"31-Jan-10") & "<br />")
document.write(MonthName(10,true)& "<br />")
fromDate="22-sep-10 00:00:00"
toDate="21-oct-10 23:59:00"
document.write(DateDiff("m",fromDate,toDate)&"<br />")
document.write(DateDiff("y",fromDate,toDate) & "<br />")
document.write(DateDiff("w",fromDate,toDate) & "<br />")
document.write(DateDiff("h",fromDate,toDate) & "<br />")
</script>
</center>
</body>
</html>

VBScript Validation Program
This is a Simple Program to Validate Age and Numeric Value using VBScript for Beginners.

<HTML>
<HEAD><TITLE>Simple Validation</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Submit_OnClick
  Dim TheForm
  Set TheForm = Document.ValidForm
  If IsNumeric(TheForm.Text1.Value) Then
    If TheForm.Text1.Value < 18 Or TheForm.Text1.Value > 40 Then
      MsgBox "Age must be above 18"
    Else
      MsgBox "Thank You"
    End If
  Else
    MsgBox "Please enter a numeric value"
  End If
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<H3>Simple Validation</H3><HR>
<FORM NAME="ValidForm">
Enter your age:
<INPUT NAME="Text1" TYPE="TEXT" SIZE="2">
<INPUT NAME="Submit" TYPE="BUTTON" VALUE="Submit">
</FORM>
</BODY>
</HTML>