Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two-dimensional array declaration

Status
Not open for further replies.

11791

Programmer
Jan 19, 2000
2
US
Can I declare a two or more dimensional array in vbscript using one line declarations? For example, a one dimensional array can be declared like this: <br>
<br>
dim weekdays(6) = (&quot;Monday&quot;, &quot;Tuesday&quot;, &quot;Wednesday&quot;, &quot;Thursday&quot;, &quot;Friday&quot;, &quot;Saturday&quot;, &quot;Sunday&quot;) <br>
(or something similar)<br>
<br>
as opposed to this:<br>
<br>
dim weekdays(6)<br>
weekdays(0) = &quot;Monday&quot;<br>
weekdays(1) = &quot;Tuesday&quot;<br>
weekdays(2) = &quot;Wednesday&quot;<br>
weekdays(3) = &quot;Thursday&quot;<br>
weekdays(4) = &quot;Friday&quot;<br>
weekdays(5) = &quot;Saturday&quot;<br>
weekdays(6) = &quot;Sunday&quot;<br>
<br>
Can this be done with a two or more dimensional array?<br>
<br>

 
I found this at:<A HREF=" TARGET="_new"> notation used to refer to an element of an array consists of the variable name followed by parentheses containing<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;an index number indicating the desired element. In the following example, the first statement creates a variable named<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A. The second statement assigns an array to variable A. The last statement assigns the value contained in the second<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;array element to another variable. <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim A<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A = Array(10,20,20)<br>...
 
You can't do an assignment and a dim on the same line.<br>You could use a method like this:<br><br>dim weekdays<br>weekdays=split(&quot;Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday&quot;, &quot;,&quot;)<br><br>This will give you an array filled with your values.<br> <p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top