Breaking News
Showing posts with label VBScript. Show all posts
Showing posts with label VBScript. Show all posts

Wednesday, July 4, 2012

Ex33: Mid function in VBScript

Return a specified number of characters from a string

<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
sometext="Welcome to our Web Site!!"
document.write(Mid(sometext, 9, 2))
</script>


</body>
</html>
Read more ...

Ex32: Replace function in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
sometext="Welcome to this Web!!"
document.write(Replace(sometext, "Web", "Page"))
</script>


</body>
</html>

Read more ...

Ex31: Char Left & Right function in VBScript

Return a specified number of characters from the left or right side of a string

<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
sometext="Welcome to our Web Site!!"
document.write(Left(sometext,5))
document.write("<br />")
document.write(Right(sometext,5))
</script>


</body>
</html>
Read more ...

Ex30: Return a random number bw 0-99 in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
Randomize()
randomNumber=Int(100 * Rnd())
document.write("A random number: <b>" & randomNumber & "</b>")
</script>


</body>
</html>
Read more ...

Ex28: Round a number in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
i = 48.66776677
j = 48.3333333
document.write(Round(i))
document.write("<br />")
document.write(Round(j))
</script>


</body>
</html>

Read more ...

Ex29: Return a random number in VBScript

<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
Randomize()
document.write(Rnd())
</script>


</body>
</html>
Read more ...

Ex27: Reverse a string in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
sometext = "Hello Everyone!"
document.write(StrReverse(sometext))
</script>


</body>
</html>

Read more ...

Ex25: Uppercase or lowercase in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
txt="Have a nice day!"
document.write(UCase(txt))
document.write("<br />")
document.write(LCase(txt))
</script>


</body>
</html>
Read more ...

Ex26: Trim function in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
fname=" Bill "
document.write("Hello" & Trim(fname) & "Gates<br />")
document.write("Hello" & RTrim(fname) & "Gates<br />")
document.write("Hello" & LTrim(fname) & "Gates<br />")
</script>


</body>
</html>
Read more ...

Ex24: Isdate function in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
somedate="10/30/99"
document.write(IsDate(somedate))
</script>


</body>
</html>
Read more ...

Ex23: Format Date and Time in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
document.write(FormatDateTime(Date(),vbGeneralDate))
document.write("<br />")
document.write(FormatDateTime(Date(),vbLongDate))
document.write("<br />")
document.write(FormatDateTime(Date(),vbShortDate))
document.write("<br />")
document.write(FormatDateTime(Now(),vbLongTime))
document.write("<br />")
document.write(FormatDateTime(Now(),vbShortTime))
</script>


<p>Syntax for FormatDateTime: FormatDateTime(Date,namedformat).</p>


</body>
</html>

Read more ...

Ex21: Countdown to year 3000 in VBScript


<!DOCTYPE html>
<html>
<body>


<p>Countdown to year 3000:</p>


<p>
<script type="text/vbscript">
millennium=CDate("1/1/3000 00:00:00")
document.write("It is " & DateDiff("yyyy", Now(), millennium) & " years to year 3000!<br />")
document.write("It is " & DateDiff("m", Now(), millennium) & " months to year 3000!<br />")
document.write("It is " & DateDiff("d", Now(), millennium) & " days to year 3000!<br />")
document.write("It is " & DateDiff("h", Now(), millennium) & " hours to year 3000!<br />")
document.write("It is " & DateDiff("n", Now(), millennium) & " minutes to year 3000!<br />")
document.write("It is " & DateDiff("s", Now(), millennium) & " seconds to year 3000!<br />")
</script>
</p>


</body>
</html>

Read more ...

Ex22: Add a time interval to a date in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
document.write(DateAdd("d",30,Date()))
</script>


<p>
This example uses <b>DateAdd</b> to calculate a date 30 days from today.
</p>
<p>
Syntax for DateAdd: DateAdd(interval,number,date).
</p>


</body>
</html>
Read more ...

Ex20: Display the current month and day in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
document.write("Today's day is " & WeekdayName(Weekday(Date)))
document.write("<br />")
document.write("The month is " & MonthName(Month(Date)))
</script>


</body>
</html>
Read more ...

Ex18: Display the days in VBScript


<!DOCTYPE html>
<html>
<body>


<p>VBScripts' function <b>WeekdayName</b> is used to get a weekday:</p>
<script type="text/vbscript">
document.write("<p>")
document.write(WeekDayName(1))
document.write("<br />")
document.write(WeekDayName(2))
document.write("</p><p>")


document.write("Get the abbreviated name of a weekday:")
document.write("<br />")
document.write(WeekDayName(1,True))
document.write("<br />")
document.write(WeekDayName(2,True))
document.write("</p><p>")


document.write("Get the current weekday:")
document.write("<br />")
document.write(WeekdayName(weekday(Date)))
document.write("<br />")
document.write(WeekdayName(weekday(Date), True))
document.write("</p>")
</script>


</body>
</html>

Read more ...

Ex19: Display the months in VBScript


<!DOCTYPE html>
<html>
<body>


<p>VBScripts' function <b>MonthName</b> is used to get a month:</p>
<script type="text/vbscript">
document.write("<p>")
document.write(MonthName(1))
document.write("<br />")
document.write(MonthName(2))
document.write("</p><p>")


document.write("Here is how you get the abbreviated name of a month:")
document.write("<br />")
document.write(MonthName(1,True))
document.write("<br />")
document.write(MonthName(2,True))
document.write("</p><p>")


document.write("Here is how you get the current month:")
document.write("<br />")
document.write(MonthName(Month(Date)))
document.write("<br />")
document.write(MonthName(Month(Date),True))
document.write("</p>")
</script>


</body>
</html>

Read more ...

Ex16: Do...While loop in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
i=0
Do While i < 10
  document.write(i & "<br />")
  i=i+1
Loop
</script>


</body>
</html>
Read more ...

Ex17: Display Date and Time in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
document.write("Today's date is " & Date())
document.write("<br />")
document.write("The time is " & Time())
</script>


</body>
</html>
Read more ...

Ex14: Looping through the HTML headers in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
For i=1 To 6
 document.write("<h" & i & ">This is header " & i & "</h" & i & ">")
Next
</script>


</body>
</html>
Read more ...

Ex15: For..Each loop in VBScript


<!DOCTYPE html>
<html>
<body>


<script type="text/vbscript">
Dim cars(2)
cars(0)="Volvo"
cars(1)="Saab"
cars(2)="BMW"


For Each x In cars
  document.write(x & "<br />")
Next
</script>


</body>
</html>
Read more ...
Designed By Published.. Blogger Templates