Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Subscript out of range

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Subscript out of range
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Subscript out of range - 5/17/2007 7:53:27 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
Hello,
Every time I try to view the next data in an array of database query information, I get this runtime error.  I do check to make sure that the array is currently not at the end to make sure there is no out of bounds exception.  The weird thing is, with certain information, it will work fine without getting the error, but with others, the error will display.  I check for the next element in the array by doing something similar to theArray(3, rowCounter + 1) as the +1 is supposed to represent the next element.

Any guidance would be appreciated.  Thanks.
 
 
Post #: 1
 
 RE: Subscript out of range - 5/19/2007 2:46:30 AM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Is the information you're getting from your database returned as a recordset or an array?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to webren)
 
 
Post #: 2
 
 RE: Subscript out of range - 5/22/2007 8:38:02 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
Array

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Subscript out of range - 5/22/2007 12:03:47 PM   
  dm_4ever


Posts: 2723
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
You might want to post what you're currently using.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to webren)
 
 
Post #: 4
 
 RE: Subscript out of range - 5/24/2007 11:21:40 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
Currently using?  I am using Microsoft's IIS server and the SQL language. 

Is there anyway to check the next element in the array without comparing arrayElement to arrayElement + 1?

(in reply to dm_4ever)
 
 
Post #: 5
 
 RE: Subscript out of range - 5/25/2007 1:10:17 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
By "using", I think we were looking for you to post the code that you are using. At least that is what would help me.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to webren)
 
 
Post #: 6
 
 RE: Subscript out of range - 5/25/2007 5:22:41 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
An example of what I am trying to do is...


      

...with theArray being a two-dimensional array and rowCounter being the rows in the database.  I clearly check to make sure that rowCounter is not at the end of the array, but even so, I get a runtime error on the line where I try to do theArray(3, rowCounter + 1).  What is weird is I will get this runtime error for some pages, and I won't for other pages.

I hope my explanation wasn't confusing, and I appreciate any guidance to solving this problem.

Thank you.

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: Subscript out of range - 5/25/2007 6:47:42 AM   
  Skie

 

Posts: 58
Score: 0
Joined: 3/2/2006
Status: offline

      

I think you just need to change the minus to a plus.

(in reply to webren)
 
 
Post #: 8
 
 RE: Subscript out of range - 5/25/2007 7:22:39 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
There is a good chance that is the fix. It depends on how the counter is initialized and incremented. That is why we need to see the code and we still haven't seen that part of the code.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Skie)
 
 
Post #: 9
 
 RE: Subscript out of range - 5/29/2007 8:19:04 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
Well, here's a basic example of what I am trying to do.  This foreach loop gives me the same Subscript out of range error.  The array is titled arr_rGet_EventInfo and is a two dimensional array, with the first parameter being the column and the second parameter being the row.

      

I am not quite sure what I am doing wrong to get the runtime error.  To my understanding, a more appropriate loop for a 2-d array would be:

      

...but I do not care about any other column except the 3rd column.  Can someone please point me in the right direction?  Thank you.

(in reply to ebgreen)
 
 
Post #: 10
 
 RE: Subscript out of range - 5/30/2007 12:34:44 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
I don't know how more plain I can be. We need to see your actual code. Examples just won't cut it. We need to see how you actually initialize and increment counters.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to webren)
 
 
Post #: 11
 
 RE: Subscript out of range - 5/30/2007 5:09:37 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
I apologize for being so vague.  I didn't want to post the actual code because of how long it is.  Here is the code:


      

Thanks for your time and help.

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: Subscript out of range - 5/30/2007 5:33:24 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Still not all of the code, but enough that we can start to unravel the issue.

Where and how is rowCounter initialized?
What does theArray look like? Could you give an example?

This line is not valid syntax
If (cols = Weekday(theArray(3, rowCounter))) And (getMonth(theArray(3, rowCounter)) =

You refer many times to a database. Is this data held in a database? If so, then there are probably better ways to access the data than multi-dimensional arrays.

In the code that you posted, difference is never actaully used for anything. What is it's purpose?

Which specific line gives you an error and what is the exact text of the error?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to webren)
 
 
Post #: 13
 
 RE: Subscript out of range - 5/30/2007 6:55:18 AM   
  webren


Posts: 16
Score: 0
Joined: 5/17/2007
From: College Park, MD
Status: offline
Warning, it's a lot of code...