All Forums >> [Scripting] >> Post a VBScript >> BOFH-style Excuse Generator Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
1) Use Option Explicit. It only seems like it causes more work. It really saves work. 2) Use block indentation. It makes code so much easier to read and understand. 3) Use a consistent variable naming convention. It also makes it much easier to understand what is going on in the code.
Those comments are all more stylistic than anything else. Here is the code with those changes:
Now for more functional suggestions:
1) There is no need for a variable to count the number of lines in the array. Use the UBound() function if you need to know how many items are in an array. 2) It is not necessary to open the textfile and read in every line. Instead, open the file read in the entire thing and split it to create your array. 3) It is not necessary to define the top and bottom indices for the array. All arrays have a lower index of 0 and UBound gives you the upper index.