VBScript program to find the line in a specified text file that corresponds to a specified line number. This can be used to determine which line in a VBScript or PowerShell program raised an error.
Error messages displayed when VBScript or PowerShell programs are run indicate the line number of the statement that raised the error. In the past, we could use the Edit program to view the program and you could tell which line corresponded to the line number. The Edit program displays the line number where the insertion point is located. In newer operating systems, the Edit program is no longer available. Like me, you may have resorted to manually counting lines as you viewed the program in Notepad. Unless you have an editor that indicates line numbers, this is time consuming and error prone. This program was developed to make this easier.
The program requires two parameters, the name of the file and the line number. The program reads the designated file, then displays the line immediately before the one specified, the specified line, and the line immediately after. The line numbers for these three lines is also displayed. This should help determine the line that corresponds to the line number. The syntax for the program would be similar to the following:
cscript //nologo FindLineNo.vbs Example.vbs 76
The resulting output could be similar to the following (note the missing quote character in line 76 that probably raised the error):
075: If (k > 0) Then
076: strValue = "Test
077: End If
FindLineNo.txt <<-- Click here to view or download the program