Avatar of Isaac
IsaacFlag for United States of America

asked on 

2 dimensional array

I'm trying to use a 2 dimensional array but it's not working.
Here's the error I get:
Microsoft VBScript runtime error (160, 11) : Subscript out of range: 'UBound'
i=0
Dim initArry()
Do While Not rs1.Eof  ' Loop for each subscribed id
 
........ASP Code.....................
 
  			   initArry(i,0) = nUsrId 
 			   initArry(i,1) = nPId    
 			   initArry(i,2) = sMailBody     
 			   
 			   ReDim Preserve initArry(i+1,2) 
........ASP Code.....................
              
 
         'ubound(array,1) returns the number of fields (columns) in the array
	'UBound(array,2) returns the number of records (rows) in the array
          maxCol = UBound(initArry,1) <----Line 160
          maxRow = UBound(initArry,2)
          
         For y=0 To maxRow      
         	WScript.Echo "user id: " & initArry(y,0) & vbCrLf
         	WScript.Echo "phasing id: " & initArry(y,1) & vbCrLf
         	WScript.Echo "Email Body: " & initArry(y,2) & vbCrLf        
         next
 
               i=i+1              
               rs1.MoveNext
            Loop

Open in new window

JavaScriptVB Script

Avatar of undefined
Last Comment
Isaac
ASKER CERTIFIED SOLUTION
Avatar of purplepomegranite
purplepomegranite
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
And for future reference, VBScript questions shouldn't be posted in the JavaScript Zone! :-)
Avatar of Isaac
Isaac
Flag of United States of America image

ASKER

Sorry about that. Posting it in a javascript zone was a mistake.
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo