Showing posts with label Visual Basics Programs. Show all posts
Showing posts with label Visual Basics Programs. Show all posts

Sunday, 26 May 2013

VBScript Validation Program

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

Generate Date and Time VBScript Program

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

Generate Days VBScript Program

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

Display Array Element in VB Script

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

Print Fibonacci series in Visual Basics

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>