Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Assigning Arrays

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Assigning 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 >>
 Assigning Arrays - 6/20/2006 1:34:41 PM   
  SuperStruct

 

Posts: 3
Score: 0
Joined: 12/12/2005
Status: offline
I need to assign one array to another. Here's my problem. I have a function that returns an array of email addresses. I want to assign this to another array like so:

Dim EmailList
EmailList = ReturnEmailArray



Function ReturnEmailArray
  Dim eArray()
  ...
  create email array here
  ...

  ReturnEmailArray = eArray
End Function


I am getting an error. Why? How can I do this problem?
 
 
Post #: 1
 
 RE: Assigning Arrays - 6/20/2006 6:24:18 PM   
  ehvbs

 

Posts: 2078
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi SuperStruct,

sorry, I can't answer your question, because this


      

works for me without any errors.

(in reply to SuperStruct)
 
 
Post #: 2
 
 RE: Assigning Arrays - 6/20/2006 6:58:04 PM   
  ginolard


Posts: 1024
Score: 21
Joined: 8/10/2005
Status: offline
This is very doable and the code below works fine


      

I notice however that you are using a dynamic array, are you initialising said array with a ReDim?  To be honest, I hardly ever use dynamic arrays as I've found that simply creating an array with more than enough elements is more performant (and, yes, lazy I know).  So, if I know that roughly I'll need 500 elements I'll Dim the array with 600 or so.  I can always Redim Preserve it with the Ubound limit of the array if I need to get rid of the unused elements.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to SuperStruct)
 
 
Post #: 3
 
 RE: Assigning Arrays - 6/21/2006 2:05:13 AM   
  SuperStruct

 

Posts: 3
Score: 0
Joined: 12/12/2005
Status: offline
Looking back in my code I have this:

Dim EmailList()
EmailList = ReturnEmailArray

I was getting a type error. I took out the paranthesis and now have this:
Dim EmailList
EmailList = ReturnEmailArray


which works correctly.

Thank you everyone!!

(in reply to SuperStruct)
 
 
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 >> Assigning 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