Connecting Tech Pros Worldwide Forums | Help | Site Map

Strange dim array problem...

Newbie
 
Join Date: Aug 2008
Posts: 1
#1: Aug 28 '08
I have this really weird problem. When I dim a dyamic array, it doesn't seem to be working... because when I access the array, I get this error:

Microsoft VBScript runtime error '800a0009'

Subscript out of range

Here's the code where I dim my array:

Expand|Select|Wrap|Line Numbers
  1. dim selectedresorg()
I then try to assign a value to the array like this:

Expand|Select|Wrap|Line Numbers
  1. selectedresorg(0) = (rsResources.Fields.Item("ORG_ID").Value)
This is where it breaks. The only way this assignment works is if I statically define the array like so:

Expand|Select|Wrap|Line Numbers
  1. dim selectedresorg(5)
Does anyone know why I'm having this issue? As far as I know, I'm defining the array correctly.

Thanks for any help.

Tom

tomgrow AT gmail

Member
 
Join Date: Aug 2008
Posts: 49
#2: Aug 29 '08

re: Strange dim array problem...


You have created an array with zero records. So you can't update a record (which is what you are trying to do) until you have at least 1 record.
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#3: Aug 30 '08

re: Strange dim array problem...


The best way I have found around this problem is to use the split() function:
Expand|Select|Wrap|Line Numbers
  1. dim longString, anArray
  2. longString = "Jim,Joe,Jerry,Jenny"
  3. longString = longString & ",Barnard"
  4. longString = longString & ",Betty"
  5.  
  6. anArray = split(longString, ",")
Let me know if this helps.

JAred
Reply