locked
VB Script to sum the same column in multiple files in the same directory RRS feed

  • Question

  • .....

    • Edited by cdtakacs1 Thursday, September 27, 2018 7:15 PM
    • Moved by Bill_Stewart Tuesday, December 11, 2018 9:15 PM User removed question
    Sunday, July 22, 2018 8:54 PM

All replies

  • Please read this first: This forum is for scripting questions rather than script requests.

    Also find scripts here: PowerShell Gallery or here: TechNet Gallery - resources for IT professionals.

    Learn PowerShell: Microsoft Virtual Academy - Getting Started with Microsoft PowerShell.

    Script requests: Microsoft Technet Script Center - Requests.

    Regardless of all that, you could make your life much easier when you use Powershell instead of VBScript. There is a module Import-Excel what makes it even more easier to acomplish what your'e asking for.


    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Sunday, July 22, 2018 11:48 PM
  • Is VB really inferior to PowerShell?

    I'm actually not able to answer this question because I never managed to learn VBScript. ;-) But I can tell that I consider it quite easy to learn the basics of Powershell. If you like to get an idea you could start to watch the free video course in the Microsoft Virtual Academy - Getting Started with Powershell.

    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Monday, July 23, 2018 10:44 PM
  • Is VB really inferior to PowerShell?

    I'm actually not able to answer this question because I never managed to learn VBScript. ;-) But I can tell that I consider it quite easy to learn the basics of Powershell. If you like to get an idea you could start to watch the free video course in the Microsoft Virtual Academy - Getting Started with Powershell.

    Best regards,

    (79,108,97,102|%{[char]$_})-join''

    Most of what we can do with PowerShell cannot be done with VBScript. VBScript is no longer supported by MS. It will disappear in a future release of Windows.   All new Windows subsystems are being released with no support for VBScript and with explicit support for PowerShell.

    Along with the above, PS is easier to learn and use and can be extended.  Current support for PS by vendors is almost total.  All major vendors are supporting or are adding support for PowerShell.  Oracle, IBM, HP, Dell and many others.

    PowerShell runs on almost all flavors of Unix and on the MAC and many smart phones.

    VBScript has no safe or useful remoting methods.

     

    \_(ツ)_/

    Monday, July 23, 2018 10:53 PM
  • Yes, VBScript is inferior to PowerShell. Most of what you can do in VBScript can be done much easier in PowerShell. In your code you did this to set FName:

    Function LPad (str, pad, length)
        LPad = String(length - Len(str), pad) & str
    End Function
    
    Dim TFile, FName, YYYY, MM, DD
    YYYY = Year(Now)
    MM = LPad(Month(Date), "0", 2)
    DD = LPad(Day(Date), "0", 2)
    FName = "Total_Headcount" & "_" & YYYY & MM & DD & ".txt"

    In PowerShell I would do something like this:

    $fname = 'Total_Headcount_{0:yyyyMMdd}.txt' -f (Get-Date)

    Tuesday, July 24, 2018 5:24 AM