I was wondering if VBScript had the capability to create a variable via a loop?
For example:
I have the following code which has to cycle through 4 different filecollections and therefor four different counters (EstaNumber?Counter, BetaNumber?Counter, CosaNumber?Counter, DeltaNumber?Counter). Each one checks for files starting with the letters A - Z, then assigns the values to buttons on the HTML page of the HTA program.
For Each fileList In filecollection
If left(fileList.Name,1) = "a" Then EstaNumberACounter = EstaNumberACounter + 1
If left(fileList.Name,1) = "b" Then EstaNumberBCounter = EstaNumberBCounter + 1 ... and it continues on down thru "z" Next EstaNumberA.value = "A " & EstaNumberACounter
EstaNumberB.value = "B " & EstaNumberBCounter ... and it continues on down thru "z"
Is there a way to create the variable name via a loop to minimize the amount of lines I'm having to code and to make it less complicated when new filecollections are added? Something like this... (which obviously doesn't work *lol* or I wouldn't be on here asking darnit!)
For Each fileList In filecollection
If left(fileList.Name,1) = "a" Then ACounter = ACounter + 1
If left(fileList.Name,1) = "b" Then BCounter = BCounter + 1 ... and it continues on down thru "z" Next LetterArray = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")
For i = 0 to 1
ThisVar = "EstaNumber" & LetterArray(i)
ThisVar.value = LetterArray(i) & " " & LetterArray(i)&"Counter" Next
This is a long shot... but hopefully someone has an idea of how to do this so I don't have several hundred lines of code for a simple directory count, and so I won't have to add 60 odd lines of code each time a new file collection is added.
<message edited by lmktx on Friday, December 02, 2011 8:55 PM>