Coding
<html>
<body>
<script language="VBScript">
name="Bill Gates"
document.write(ucase(name))
document.write("<br />")
document.write(lcase(name))
</script>
</body>
</html>
Output
BILL GATES
bill gates
2. This example demonstrates how you can use the Trim, LTrim
and RTrimfunctions. The first function returns a
string without leading and trailing spaces, the second function
a string without leading spaces, the third function returns a
string without trailing spaces.
Coding
<html>
<body>
<script language="VBScript">
name = " Bill "
document.write("Hello" & trim(name) & "Gates<br />")
document.write("Hello" & rtrim(name) & "Gates<br />")
document.write("Hello" & ltrim(name) & "Gates<br />")
</script>
</body>
</html>
Output
HelloBillGates
Hello BillGates
HelloBill Gates
3. This example demonstrates how you can use the StrReverse
function. This functions reverse a string.
Coding
<html>
<body>
<script language="VBScript">
sometext = "Hallo Everyone!"
document.write(strReverse(sometext))
</script>
</body>
</html>
Output
!enoyrevE ollaH
4. This example demonstrates how you can use the Round
function. This functions round a number.
Coding
<html>
<body>
<script language="VBScript">
i = 48.66776677
j = 48.3333333
document.write(Round(i))
document.write("<br />")
document.write(Round(j))
</script>
</body>
</html>
Output
49
48
5. This example demonstrates how you can use the Rnd and
the Randomize functions. This functions returns a random
number.
Coding
<html>
<body>
<script language="VBScript">
randomize()
document.write(Rnd())
</script>
</body>
</html>
Output
0.1347772
6. This example uses the functions: Rnd, Int, and
randomize, to return a random number between 0 and 99.
Coding
<html>
<body>
<script language="VBScript">
randomize()
randomNumber=Int(100 * rnd())
document.write("A random number: <b>" & randomNumber & "</b>")
</script>
</body>
</html>
Output
A random number: 19
7. This example demonstrates how you can use the Left and
Right functions. These functions returns a specified
number of characters from the left or right side of a string.
Coding
<html>
<body>
<script language="VBScript">
sometext="Welcome to our Web Site!!"
document.write(Left(sometext,5))
document.write("<br />")
document.write(Right(sometext,5))
</script>
</body>
</html>
Output
Welco
ite!!
8. This example demonstrates how you can use the Replace
function. This function returns a string in which a specified
sub-string has been replaced with another sub string a specified
number of times.
Coding
<html>
<body>
<script language="VBScript">
sometext="Welcome to this Web!!"
document.write(Replace(sometext, "Web", "Page"))
</script>
</body>
</html>
Output
Welcome to this Page!!
9. This example demonstrates how you can use the Mid
function. This function returns the characters you specify,
example: mid(str,9,2) returns two characters from character
number 9.
Coding
<html>
<body>
<script language="VBScript">
sometext="Welcome to our Web Site!!"
document.write(Mid(sometext, 9, 2))
</script>
</body>
</html>
Output
to