VBScript: More String Functions - Right Ahead
(Page 3 of 6 )
The Right() function works like the Left() function except that it takes characters starting from the right hand side. The easiest way to explain it is to show it in action:
<html>
<body>
<script type="text/vbscript">
document.write(Right("Yo mama so ugly she made an onion cry",9))
</script>
</body>
</html>
This code counts back from the end of the sentence, grabs the last nine characters and gives us the result of:
onion cry
Once again, you can also use it on variables, like so:
<html>
<body>
<script type="text/vbscript">
ugly="Yo mama so ugly she made an onion cry"
document.write(Right(ugly,9))
</script>
</body>
</html>
Giving us the same result as before:
onion cry
And if we enter in too many characters to parse:
<html>
<body>
<script type="text/vbscript">
ugly="Yo mama so ugly she made an onion cry"
document.write(Right(ugly,10000))
</script>
</body>
</html>
It simply prints the whole string:
Yo mama so ugly she made an onion cry
Next: The Middle Man >>
More Windows Scripting Articles
More By James Payne