Solved

VBScript Create a variable name from a variable

Posted on 2009-04-07
9
394 Views
Last Modified: 2012-05-06
I need the below script to output 0, 5, and 10 without if statments by changing strTest into one of the intTest's based off of what intRunning is.  
intTest1 = 0

intTest2 = 5

intTest3 = 10

intRunning = 1
 
 

Do While intRunning < 4

strTest = "intTest" & intRunning

wscript.echo strTest

intRunning = intRunning + 1
 

Loop

Open in new window

0
Comment
Question by:JesseWH
9 Comments
 
LVL 8

Expert Comment

by:jwarnken
Comment Utility

intTest1 = 0

intTest2 = 5

intTest3 = 10

intRunning = 1

 

 

Do While intRunning < 4

Select Case intRunning 

Case 1 

strTest = intTest1

Case 2 

strTest = intTest2

Case 3 

strTest = intTest3

End Select

wscript.echo strTest

intRunning = intRunning + 1

 

Loop

Open in new window

0
 

Author Comment

by:JesseWH
Comment Utility
I need to actualy change strTest into whatever int test would be represented for example say

intRunning = 1
and
intTest1 = "Hello"

I need

strTest = "intTest" & intrunning

to become intTest1 so that whenever I

wscript.echo strTest it outputs Hello

I hope that makes sence.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
usually, you don't want to do it that way, but instead create an array or collection with the data:
Dim intTest
set intTest = new Collection
intTest("t1") = 0
intTest("t2") = 5
intTest("t3") = 10 
intRunning = 1 
Do While intRunning < 4
  strTest = "T" & intRunning
  wscript.echo intTest(strTest)
  intRunning = intRunning + 1 
Loop

Open in new window

0
 

Author Comment

by:JesseWH
Comment Utility
Hmm I dont think that will work because the diffrent intTest's will be changing as the scripts runs so they are not constant.  And I will need to beable to go back to them add and subtract from each one as the script goes along.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:JesseWH
Comment Utility
Just so you can kind of see where I am coming from I've included the actual script I'm making.  It goes through and counts the number of users on each mailbox store and adds that number into intCount and a number later on it will go through and moves users around based on an optimal number and when a user gets moved to or from a mailbox store add or subtract one from the respective into count.  I need the variable name that has a variable as part of the name so that I can go through and say something along the lines of...

intCount1 = 1544
intCount2 = 1896
intCount3 = 1256
(The above numbers will change as the script is running and represent the number of users in a mailbox store)
intOptimal = 1565 ' This number does not change

intRunning = 2
strCount = "intCount" & intRunning
Do While intcount1 > intOptimal + 5
strCount = "intCount" & intRunning
If strCount < intOptimal Then 'strCount should be intCount2
'Move the mailbox to the respective mailbox store
intCount1 = intCount1 - 1
strCount = strCount + 1' Again this should add one to intCount2
Else
intRunning = intRunning + 1
End If


Sorry I know thats kind of crazy...



 
'On Error Resume Next

Dim cComputerName

Const cWMINameSpace = "root/MicrosoftExchangeV2"

Const cWMIInstance = "Exchange_Mailbox"

Set ObjFSO = CreateObject("Scripting.FileSystemObject")

Set rootDSE = GetObject("LDAP://RootDSE")

DomainContainer = rootDSE.Get("defaultNamingContext")

Set ObjLog = ObjFSO.OpenTextFile("Log.txt", 2, True)

Set ObjUser = ObjFSO.OpenTextFile("User.txt", 2, True)

Set ObjProlbem = ObjFSO.OpenTextFile("Prolbem.txt", 2, True)
 
 
 

Dim arrDN()

Dim strWinMgmts            ' Connection string for WMI

Dim objWMIExchange   ' Exchange Namespace WMI object

Dim listExchange_Mailboxs  ' ExchangeLogons collection

Dim objExchange_Mailbox           ' A single ExchangeLogon WMI object
 

intCount = 0

intRunning = 1
 

'=====================================================================================
 

objStore1 = "B"

objSG1 = "SG1" 

objServer1 = "spcrexeizn003"

objAdminGroup1 = "SPCR"

intCount1 = 0

Dim arrDN1()
 

objStore2 = "C"

objSG2 = "SG1" 

objServer2 = "spcrexeizn003"

objAdminGroup2 = "SPCR"

intCount2 = 0

Dim arrDN2()
 

objStore3 = "b"

objSG3 = "SG1" 

objServer3 = "SPEIEXMBVS02N"

objAdminGroup3 = "SPCR"

intCount3 = 0

Dim arrDN3()
 

objStore4 = "b"

objSG4 = "SG1" 

objServer4 = "SPEIEXMBVS02N"

objAdminGroup4 = "SPCR"

intCount4 = 0

Dim arrDN4()
 

objStore5 = "b"

objSG5 = "SG1" 

objServer5 = "SPEIEXMBVS03N"

objAdminGroup5 = "SPCR"

intCount5 = 0

Dim arrDN5()
 

objStore6 = "b"

objSG6 = "SG1" 

objServer6 = "SPEIEXMBVS03N"

objAdminGroup6 = "SPCR"

intCount6 = 0

Dim arrDN6()
 

objStore7 = "b"

objSG7 = "SG1" 

objServer7 = "SPEIEXMBVS04N"

objAdminGroup7 = "SPCR"

intCount7 = 0

Dim arrDN7()
 

objStore8 = "b"

objSG8 = "SG1" 

objServer8 = "SPEIEXMBVS04N"

objAdminGroup8 = "SPCR"

intCount8 = 0

Dim arrDN8()
 

'=====================================================================================
 

	If intRunning = 1 Then

		objStore = objStore1

		objSG = objSG1

		objServer = objServer1

		objAdminGroup = objAdminGroup1
 

		ListStoreSub
 

		intCount1 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1

		

		For Each strDN in arrDN

    	'Wscript.Echo strDN

    	ReDim Preserve arrDN1(intCount)

			arrDN1(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

				

				

		For Each strDN in arr1DN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN1(intCount)

			arrDN1(intCount) = strDN

			intCount = intCount + 1

		Next

		

	End If  

		

	If intRunning = 2 Then

		
 

		objStore = objStore2

		objSG = objSG2

		objServer = objServer2

		objAdminGroup = objAdminGroup2

		

		ListStoreSub
 

		intCount2 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1

			

			

			For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN2(intCount)

			arrDN2(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

		

	End If 
 
 

	If intRunning = 3 Then

		
 

		objStore = objStore3

		objSG = objSG3

		objServer = objServer3

		objAdminGroup = objAdminGroup3
 

		ListStoreSub
 

		intCount3 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1

		

		For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN3(intCount)

			arrDN3(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0
 

	End If 
 

	If intRunning = 4 Then

		
 

		objStore = objStore4

		objSG = objSG4

		objServer = objServer4

		objAdminGroup = objAdminGroup4
 

		ListStoreSub
 

		intCount4 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1
 

		For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN4(intCount)

			arrDN4(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

		

	End If 
 

	If intRunning = 5 Then

		
 

		objStore = objStore5

		objSG = objSG5

		objServer = objServer5

		objAdminGroup = objAdminGroup5
 

		ListStoreSub
 

		intCount5 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1
 

		For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN5(intCount)

			arrDN5(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

		

	End If 
 

	If intRunning = 6 Then

		
 

		objStore = objStore6

		objSG = objSG6

		objServer = objServer6

		objAdminGroup = objAdminGroup6
 

		ListStoreSub
 

		intCount6 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1
 

		For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN6(intCount)

			arrDN6(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

		

	End If 
 

	If intRunning = 7 Then

		
 

		objStore = objStore7

		objSG = objSG7

		objServer = objServer7

		objAdminGroup = objAdminGroup7
 

		ListStoreSub
 

		intCount7 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1
 

		For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN7(intCount)

			arrDN7(intCount) = strDN

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

		

	End If 
 

	If intRunning = 8 Then

		
 

		objStore = objStore8

		objSG = objSG8

		objServer = objServer8

		objAdminGroup = objAdminGroup8
 

		ListStoreSub
 

		intCount8 = intCount

		Wscript.echo "|||||||||||| There are " & intCount & " mailboxes curently in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer 

		ObjLog.WriteLine("There are " & intCount & " mailboxes in " & objStore & " mailbox store in " & objSG & " Storage Group on " & objServer & " prior to balancing.")

		intCount = 0

		intRunning = intRunning + 1
 

		For Each strDN in arrDN

    	Wscript.Echo strDN

    	ReDim Preserve arrDN8(intCount)

			arrDN8(intCount) = strDN 

			intCount = intCount + 1

		Next

		Erase arrDN

		intCount = 0

		

	End If 
 

intMailboxes = intCount1 + intCount2 + intCount3 + intCount4 + intCount5 + intCount6 + intCount7 + intCount8
 

Wscript.Echo intMailboxes

ObjLog.WriteLine("There are " & intMailboxes & " total.")
 

intOptMailboxesLong = intMailboxes / 8

intOptMailboxes = (Round(intOptMailboxesLong))

Wscript.echo intOptMailboxes & " Was " & intOptMailboxesLong
 
 
 

intSubCount = 2

intYesNo = 0

Do While intCount1 > intOptMailboxes + 5

	If ???????????????????????????????

	

	

	

	

Loop
 
 
 
 
 
 
 
 
 
 
 
 
 

'=====================================================================================
 
 
 
 
 
 
 
 
 
 
 
 
 

Sub ListStoreSub
 
 

cComputerName = objServer

strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& cComputerName&"/"&cWMINameSpace

Set objWMIExchange =  GetObject(strWinMgmts)

' Verify we were able to correctly set the object.

If Err.Number <> 0 Then

  WScript.Echo "ERROR: Unable to connect to the WMI namespace."

Else
 

  Set listExchange_Mailboxs = objWMIExchange.InstancesOf(cWMIInstance)
 

  If (listExchange_Mailboxs.count > 0) Then
 

    For Each objExchange_Mailbox in listExchange_Mailboxs

			If IsUserinDB (objExchange_Mailbox.MailboxDisplayName)= True Then 

				

				strUserDisplayName = objExchange_Mailbox.MailboxDisplayName 

				WScript.echo strUserDisplayName

				strUserDN = SearchDistinguishedName(strUserDisplayName)

				ObjUser.WriteLine(strUserDN)

				

				ReDim Preserve arrDN(intCount)

				arrDN(intCount) = strUserDN

				

				

				

				intCount = intCount + 1

				wscript.echo intCount 

			End If

    Next

  		Else
 

    WScript.Echo "WARNING: No Exchange_Mailbox instances were returned."

  End If

  

End If
 

End Sub
 
 
 
 
 
 
 
 

Sub Count1Sub

	

		strServer  = "TAJIEXMBVS01N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 1" ' Name of the Store

		

		

End Sub
 

Sub Count2Sub
 

		strServer  = "TAJIEXMBVS02N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 1" ' Name of the Store
 

		

End Sub
 

Sub Count3Sub		
 
 

		strServer  = "TAJIEXMBVS03N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 1" ' Name of the Store

		
 

End Sub
 

Sub Count4Sub
 

		

		strServer  = "SPEIEXMBVS04N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 1" ' Name of the Store
 

		

End Sub
 

Sub Count5Sub		

	

		strServer  = "TAJIEXMBVS01N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 2" ' Name of the Store
 

End Sub
 

Sub Count6Sub
 

		strServer  = "TAJIEXMBVS02N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 2" ' Name of the Store

		

End Sub
 

Sub Count7Sub
 

		strServer  = "TAJIEXMBVS03N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 2" ' Name of the Store

		

End Sub
 

Sub Count8Sub
 

		strServer  = "SPEIEXMBVS04N"         ' Name of the Exchange Server

		strSGName  = "SG1"      ' e.g. Name of the Storage Group

		strMailStoreName = "Regular Users 2" ' Name of the Store
 

End Sub
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Function IsUserinDB (strDisplayName)
 

IsUserinDB = False

Set conn = CreateObject("ADODB.Connection")

conn.Provider = "ADSDSOObject"

conn.Open "ADs Provider"
 

' The LDAP String is a query that checks whether there is a user with the on the DB1 mailbox store

' Of the SG2 Storage Group and the rest of the information belonging to my test server. 

' You should change this to match the information of your environment.
 

ldapStr = "<LDAP://" & DomainContainer & ">;(&(&(&(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(homeMDB=CN=" & objStore & ",CN=" & objSG & ",CN=InformationStore,CN=" & objServer & ",CN=Servers,CN=" & objAdminGroup & ",CN=Administrative Groups,CN=ORGANIZATION,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=SWA,DC=CENTCOM,DC=MIL)) )))(objectCategory=user)(displayName=" & StrDisplayName & ")));adspath;subtree"
 

Set rs = conn.Execute(ldapStr)

If rs.RecordCount = 1 Then IsUserinDB = True
 

conn.Close
 

End Function
 
 
 
 

Public Function SearchDistinguishedName(vSAN)

    ' Function:     SearchDistinguishedName

    ' Description:  Searches the DistinguishedName for a given Display Name

    Dim objRootDSE, objConnection, objCommand, objRecordSet
 

    Set objRootDSE = GetObject("LDAP://rootDSE")

    Set objConnection = CreateObject("ADODB.Connection")

    objConnection.Open "Provider=ADsDSOObject;"

    Set objCommand = CreateObject("ADODB.Command")

    objCommand.ActiveConnection = objConnection

    objCommand.CommandText = "<LDAP://" & objRootDSE.get("defaultNamingContext") & ">;(&(objectCategory=*)(Displayname=" & vSAN & "));distinguishedName;subtree"

    Set objRecordSet = objCommand.Execute

    On Error Resume Next

    SearchDistinguishedName = objRecordSet.Fields("DistinguishedName")

    'On Error GoTo 0

    objConnection.Close

    Set objRecordSet = Nothing

    Set objCommand = Nothing

    Set objConnection = Nothing

    Set objRootDSE = Nothing

End Function
 
 

ObjLog.close

ObjUser.close

ObjProlbem.close 

Open in new window

0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

Personally I would create a Dictionary object for the listing in each store.

The current number of users would be referenced by the Count property of each dictionary. Then it's simply a case of Adding / Removing from each dictionary until the size of each is within your requirements.

There's no need to have all this complex variable naming to achieve what you want here.

I've done this kind of thing before for Exchange, I'll dig it out and show you what I mean.

Chris
0
 

Author Comment

by:JesseWH
Comment Utility
Thanks Chris
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
Comment Utility

Here we go.

This script does the following:

1. Reads the configured Private Information Stores from Active Directory
2. Reads the configured users from the current domain and gets their current store
3. Counts the users in each store
4. Calculates an average
5. Attempts to make all stores fit within that average
6. Returns a dictionary object containing the distinguished name of the user, and the destination store if it has decided they need moving (it doesn't do anything with that at the moment, just echos the count)

When I'm using GetStores I tend to pop in a separate subroutine to filter out any stores I'm not interested in (normally that's by Exchange server name) because it will return all stores in the Forest which may not be so helpful. Is that likely to be needed here?

Chris


' How far from optimal / average the store count can be before it is considered acceptable

Const OPTIMAL_VARIANCE = 1
 

Function GetStores

  ' Return Type: Dictionary

  '

  ' Finds all Exchange Private Information Stores from AD
 

  Dim objStores : Set objStores = CreateObject("Scripting.Dictionary")

  objStores.CompareMode = VbTextCompare
 

  Dim objConnection : Set objConnection = CreateObject("ADODB.Connection")

  objConnection.Provider = "ADsDSOObject"

  objConnection.Open "Active Directory Provider"
 

  Dim objRootDSE : Set objRootDSE = GetObject("LDAP://RootDSE")

  Dim objRecordSet : Set objRecordSet = objConnection.Execute( _

    "<LDAP://" & objRootDSE.Get("configurationNamingContext") & ">;" &_

    "(objectClass=msExchPrivateMDB);distinguishedName;subtree")

  Set objRootDSE = Nothing
 

  While Not objRecordSet.EOF

    objStores.Add objRecordSet.Fields("distinguishedName").Value, 0

    objRecordSet.MoveNext

  WEnd
 

  Set objRecordSet = Nothing

  Set objConnection = Nothing
 

  Set GetStores = objStores

End Function
 

Function GetUserStores

  ' Return Type: Dictionary

  '

  ' Finds all Exchange users and returns a dictionary containing user DN and store DN
 

  Dim objUsers : Set objUsers = CreateObject("Scripting.Dictionary")

  objUsers.CompareMode = VbTextCompare
 

  Dim objConnection : Set objConnection = CreateObject("ADODB.Connection")

  objConnection.Provider = "ADsDSOObject"

  objConnection.Open "Active Directory Provider"
 

  Dim objRootDSE : Set objRootDSE = GetObject("LDAP://RootDSE")

  Dim objRecordSet : Set objRecordSet = objConnection.Execute( _

    "<LDAP://" & objRootDSE.Get("defaultNamingContext") & ">;" &_

    "(&(objectClass=user)(objectCategory=person)(homeMDB=*));distinguishedName,homeMDB;subtree")

  Set objRootDSE = Nothing
 

  While Not objRecordSet.EOF

    objUsers.Add objRecordSet.Fields("distinguishedName").Value, objRecordSet.Fields("homeMDB").Value

    objRecordSet.MoveNext

  WEnd
 

  Set objRecordSet = Nothing

  Set objConnection = Nothing
 

  Set GetUserStores = objUsers

End Function
 

Sub ShowStoreUserCount
 

  Dim strStore

  For Each strStore in objStores

    WScript.Echo strStore & " : " & objStores(strStore)

  Next

End Sub
 

Function RecalculateStores
 

  Dim objMoveUserToStore : Set objMoveUserToStore = CreateObject("Scripting.Dictionary")

 

  For Each strUser in objUsers
 

    ' Is my store oversize?

    intNumberInStore = objStores(objUsers(strUser))
 

    If intNumberInStore > intOptimal + OPTIMAL_VARIANCE Then
 

      ' Find a new store

      For Each strStore in objStores

        If objStores(strStore) < intOptimal - OPTIMAL_VARIANCE Then

          Dim strNewStore : strNewStore = strStore

          Exit For

        End If

      Next
 

      ' Decrement the count for the current store

      objStores(objUsers(strUser)) = objStores(objUsers(strUser)) - 1

      ' Increment the count for the new store

      objStores(strNewStore) = objStores(strNewStore) + 1
 

      ' Write the that this one changes

      objMoveUserToStore.Add strUser, strNewStore
 

    End If

  Next
 

  Set RecalculateStores = objMoveUserToStore

End Function
 

'

' Main Code

'
 

Dim objStores : Set objStores = GetStores

Dim objUsers : Set objUsers = GetUserStores
 

Dim strUser

For Each strUser in objUsers

  If objStores.Exists(objUsers(strUser)) Then

    objStores(objUsers(strUser)) = objStores(objUsers(strUser)) + 1

  End If

Next
 

WScript.Echo "Store Usage before optimisation:"

WScript.Echo

ShowStoreUserCount

WScript.Echo
 

' The optimal is an average of users accross stores

Dim intOptimal : intOptimal = Round(objUsers.Count / objStores.Count)

WScript.Echo "Calculated Optimal: " & intOptimal

WScript.Echo
 

' Declare new dictionaries to hold the modified store information

Dim objMoveUserToStore : Set objMoveUserToStore  = RecalculateStores
 

WScript.Echo "Store Usage after optimisation:"

WScript.Echo

ShowStoreUserCount

WScript.Echo
 

WScript.Echo "Number of users to move: " & objMoveUserToStore.Count

Open in new window

0
 

Author Comment

by:JesseWH
Comment Utility
Ok I was playing with that and it kind of works but not exactly.  I would need to pull the last user off of each list for it to be acurate which would cause me to bounce around the same users all of the time. I would like to pull a random user which would be easy if I could get this whole variable variable thing to work something I was playing with was the execute function and I think it might be seeing it as the actual variable.
intTest1 = 0

intTest2 = 5

intTest3 = 10

intRunning = 2
 
 

Do While intRunning < 4

intTest = Execute("intTest" & intRunning)

wscript.echo intTest

intRunning = intRunning + 1
 

Loop

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now