VBScript

The Seven Deadly Sins of VBScript!

(well not really deadly ... except to your code)

Here are seven common VBScript errors - can you spot them all?

Number One

<script language="vbscript">
<!--
window_onload()
msgbox "Howdy folk!"
end sub
-->
</script>

Number Two

<script language="vbscript">
<!--
sub window_onload()
msgbox Howdy folk!
end sub
-->
</script>

Number Three

<script language="vbscript">
<!--
<!-- this script is triggered by the window_onload event and displays a message box -->
sub window_onload()
msgbox "Howdy folk!"
end sub
-->
</script>

Number Four

<script language="vbs">
<!--
sub window_onload()
msgbox "Howdy folk!"
end sub
-->
</script>

Number Five

<script language="vbscript">
<!--
sub windoe_onload()
msgbox "Howdy folk!"
end sub
-->
</script>

Number Six

<!--
<script language="vbscript">
sub window_onload()
msgbox "Howdy folk!"
end sub
</script>
-->

Number Seven

<script language="vbscript">
<!--
sub window_onload()
msgbox "Howdy folk!"
-->
</script>

ANSWERS

1 Missing sub in procedure name.
REMEDY: Put the sub and end sub in first to avoid this mistake in the beginning.

2 Missing quotes around the message to be displayed in the message box.
REMEDY: Add them!

3 Incorrect comment tag for the comment in the script inside the script block.
REMEDY: Remember, big comment tags (<!-- and -->) to surround the contents of the script block and
small comment tags (') at the beginning on any comments you place in the script.

4 Trick question - there's nothing wrong here. You can use either language="vbscript" or
language="vbs" (or any variation of upper and lower case) to declare the language type.

5 Simple typos can bring scripts crashing down around your ears! Spelt window as windoe!
This is one that I do OCCASIONALLY too! ;o)
REMEDY: Check spellings and try again!

6 Got the right comment tags but they have been placed outside the script block, thus hiding
it from even IE 4/5+!
REMEDY: Put them in the right place and try the script again.

7 Missing end sub. Similar to problem 1.
REMEDY: As problem 1. Put the sub and end sub in first to avoid this mistake in the beginning.

Kathie Kingsley-Hughes
Last updated: May 4th 2004
Print This Page   |   Email me when this page changes    |  Search This Site



Crucial.com System Scanner does the work for you!



/a_global/close_links.inc"); ?>

Contact Us