Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Collections & Arrays

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,54661
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Collections & Arrays
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Collections & Arrays - 12/20/2007 10:13:40 PM   
  bluwe

 

Posts: 5
Score: 0
Joined: 12/20/2007
Status: offline
Hello,

I've done a search but I can't find an answer to the problem I'm having. Is there a way of converting a collection into an array? I am using the following code to retrieve the names and sizes of all .jpg files on a workstation.


      

Is there a way to convert colFiles into a multidimensional array? This is because need to add the sizes of all the jpg files to find the total amount of storage they are using.

Thanks,

James
 
 
Post #: 1
 
 RE: Collections & Arrays - 12/20/2007 11:01:12 PM   
  bluwe

 

Posts: 5
Score: 0
Joined: 12/20/2007
Status: offline
It's okay. I managed to figure out a way to do it. Here's what I did:


      

Thanks anyway,

James

(in reply to bluwe)
 
 
Post #: 2
 
 RE: Collections & Arrays - 12/20/2007 11:41:20 PM   
  ehvbs

 

Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi bluwe,

why use an array? Why not

  strComputer = "."
  Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  Set colFiles = objWMIService.ExecQuery ("SELECT FileSize FROM CIM_DataFile WHERE Extension = 'jpg'")
  intSize = 0
  For Each objFile in colFiles
         intSize = intSize + objFile.FileSize
  Next
  WScript.Echo "intSize:", intSize

BTW: who is objService?

Regards

ehvbs

(in reply to bluwe)
 
 
Post #: 3
 
 RE: Collections & Arrays - 12/21/2007 12:00:27 AM   
  bluwe

 

Posts: 5
Score: 0
Joined: 12/20/2007
Status: offline
quote:


BTW: who is objService?


I was getting confused, it should have been objFile. I'm just a beginner at the moment!

Cheers,

James


(in reply to bluwe)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Collections & Arrays Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts