Re: Count lines in another VBS file

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"XP" <XP@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:9A8CC378-D10D-4DE8-A487-C4EB3786CFD6@xxxxxxxxxxxxxxxx
I would like to code a VBS file that counts all the lines in another VBS
file
by adding a CONST to the full file name of the target.

Can someone help me with that?

Thanks much in advance.

Maybe you want to pass the filename and path of the "target" *.vbs files as
an argument to the VBScript program. If so, the code posted previously could
be revised as follows to accept an argument:
==========
' Make sure one argument passed to the program.
If (Wscript.Arguments.Count <> 1 0) Then
Wscript.Echo "Require argument missing"
Wscript.Quit
End If

' Read the first argument (index 0).
strFile = Wscript.Arguments(0).

Set FSO = CreateObject("Scripting.FileSystemObject")
Set inFile = FSO.OpenTextFile(strFile)
lines = Split( inFile.ReadAll, vbLF )
lineCount = UBound(lines) ' assumes last line ends with line break
Wscript.Echo "Number of lines: " & lineCount

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Finding a word and displaying results
    ... Dim target as Document ... Set target = Documents.Add ... Doug Robbins - Word MVP ... I'm just returning the filename in a msgBox. ...
    (microsoft.public.word.vba.beginners)
  • Re: Finding a word and displaying results
    ... > Dim target as Document ... > Doug Robbins - Word MVP ... I'm just returning the filename in a msgBox. ...
    (microsoft.public.word.vba.beginners)
  • Size limit on filename created by zip?
    ... When it is less than 73 characters then zip works fine. ... is generated by combining the original filename, version, and creation ... Zip special compilation options: ... The target disk has plenty of space and is ODS-2 ...
    (comp.os.vms)
  • RE: If object exists in mdb
    ... Dim db As Database, rs As Recordset ... Set db = CurrentDb() ... 'Set db = OpenDatabase("path and filename of target db") ...
    (microsoft.public.access.modulesdaovba)
  • Re: CPYTOSTMF Need Help CPFA097 Error
    ... The helptext to the cmd ... indicates some diagnostics may be generated if the target is in ... it work OK if you change the filename to be shorter eg '/M091605.txt' ...
    (comp.sys.ibm.as400.misc)