<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: VBScript Array Length</title>
	<atom:link href="http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/</link>
	<description>when you find QWERTY imprinted on your cheek - it&#039;s time to go to bed.</description>
	<lastBuildDate>Thu, 19 May 2011 05:13:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Alex</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-84889</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Mon, 15 Mar 2010 14:14:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-84889</guid>
		<description>@Amar
Not so. The Preserve keyword on the ReDim keeps all the existing data in the array intact. Although if memory serves me correctly the syntax is with Preserve directly following the ReDim statement.

ReDim Preserve DynamicArray(10)

@0xG
Another way I found of getting around the error generated is to ReDim your dynamic array right after declaring it. That then gives you a ubound to work with from the start.

Dim Dynamic()
ReDim Dynamic(0)

WScript.Echo â€œArray size is â€ &amp; UBound(Dynamic)

You can then go on to do your other processing too as per the example in LAYGO&#039;s loop.</description>
		<content:encoded><![CDATA[<p>@Amar<br />
Not so. The Preserve keyword on the ReDim keeps all the existing data in the array intact. Although if memory serves me correctly the syntax is with Preserve directly following the ReDim statement.</p>
<p>ReDim Preserve DynamicArray(10)</p>
<p>@0xG<br />
Another way I found of getting around the error generated is to ReDim your dynamic array right after declaring it. That then gives you a ubound to work with from the start.</p>
<p>Dim Dynamic()<br />
ReDim Dynamic(0)</p>
<p>WScript.Echo â€œArray size is â€ &amp; UBound(Dynamic)</p>
<p>You can then go on to do your other processing too as per the example in LAYGO&#8217;s loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amar</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-80204</link>
		<dc:creator>Amar</dc:creator>
		<pubDate>Sat, 09 Jan 2010 01:37:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-80204</guid>
		<description>Problem in above solution is, every time when Array is redimed previous value will be get flushed out, so only last value will be stored</description>
		<content:encoded><![CDATA[<p>Problem in above solution is, every time when Array is redimed previous value will be get flushed out, so only last value will be stored</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LAYGO</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-77989</link>
		<dc:creator>LAYGO</dc:creator>
		<pubDate>Wed, 09 Dec 2009 16:10:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-77989</guid>
		<description>Frederic is right.

If you want a true dynamic array:

Dim DynamicArray()

For x = 0 To n
   ReDim DynamicArray(x) Preserve
   &#039; some processing here
   DynamicArray(x) = &quot;results of some processing here&quot;
Next
</description>
		<content:encoded><![CDATA[<p>Frederic is right.</p>
<p>If you want a true dynamic array:</p>
<p>Dim DynamicArray()</p>
<p>For x = 0 To n<br />
   ReDim DynamicArray(x) Preserve<br />
   &#8216; some processing here<br />
   DynamicArray(x) = &#8220;results of some processing here&#8221;<br />
Next</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chaitanya</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-59339</link>
		<dc:creator>chaitanya</dc:creator>
		<pubDate>Mon, 13 Apr 2009 09:59:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-59339</guid>
		<description>Size means bytelength of content</description>
		<content:encoded><![CDATA[<p>Size means bytelength of content</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chaitanya</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-59335</link>
		<dc:creator>chaitanya</dc:creator>
		<pubDate>Mon, 13 Apr 2009 09:44:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-59335</guid>
		<description>Hi every one,

               I need to find the number of bytes occupied by a array variable.Can any one help me please.</description>
		<content:encoded><![CDATA[<p>Hi every one,</p>
<p>               I need to find the number of bytes occupied by a array variable.Can any one help me please.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frederic Duplessis</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-56167</link>
		<dc:creator>Frederic Duplessis</dc:creator>
		<pubDate>Thu, 19 Mar 2009 21:01:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-56167</guid>
		<description>Dynamic arrays can NOT be defined as &quot;dummy&quot; was suggesting &lt;code&gt;Dim dynamic (0)&lt;/code&gt;.

In VBScript, the subscript in Dim statement really is what will be returned via UBound function, which is namely the highest subscript one may use to refer to an element in the array and NOT the size of it. Thus this statement &lt;code&gt;Dim dynamic (0)&lt;/code&gt; would really create an fixed-size, non-dynamic, array variable containing one element accessible with subscript 0.

Dave&#039;s solution seems the only avenue here.</description>
		<content:encoded><![CDATA[<p>Dynamic arrays can NOT be defined as &#8220;dummy&#8221; was suggesting <code>Dim dynamic (0)</code>.</p>
<p>In VBScript, the subscript in Dim statement really is what will be returned via UBound function, which is namely the highest subscript one may use to refer to an element in the array and NOT the size of it. Thus this statement <code>Dim dynamic (0)</code> would really create an fixed-size, non-dynamic, array variable containing one element accessible with subscript 0.</p>
<p>Dave&#8217;s solution seems the only avenue here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Irving</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-53718</link>
		<dc:creator>Mike Irving</dc:creator>
		<pubDate>Thu, 26 Feb 2009 17:02:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-53718</guid>
		<description>The loop counter is very useful, shame there is now built in loop property.</description>
		<content:encoded><![CDATA[<p>The loop counter is very useful, shame there is now built in loop property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dummy</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-34289</link>
		<dc:creator>dummy</dc:creator>
		<pubDate>Mon, 27 Oct 2008 11:08:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-34289</guid>
		<description>Give your dynamic array a size of 0:

Dim Dynamic(0)

Then it won&#039;t error because it will have a length.</description>
		<content:encoded><![CDATA[<p>Give your dynamic array a size of 0:</p>
<p>Dim Dynamic(0)</p>
<p>Then it won&#8217;t error because it will have a length.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 0xG</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-28604</link>
		<dc:creator>0xG</dc:creator>
		<pubDate>Wed, 10 Sep 2008 14:49:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-28604</guid>
		<description>What is even more perplexing is how to determine number if elements in a dynamic array. For instance:

Dim Dynamic()
WScript.Echo &quot;Array size is &quot; &amp; UBound(Dynamic)

&gt;Microsoft VBScript runtime error: Subscript out of range</description>
		<content:encoded><![CDATA[<p>What is even more perplexing is how to determine number if elements in a dynamic array. For instance:</p>
<p>Dim Dynamic()<br />
WScript.Echo &#8220;Array size is &#8221; &amp; UBound(Dynamic)</p>
<p>&gt;Microsoft VBScript runtime error: Subscript out of range</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave S</title>
		<link>http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/comment-page-1/#comment-17717</link>
		<dc:creator>Dave S</dc:creator>
		<pubDate>Thu, 07 Feb 2008 19:03:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.keyboardface.com/archives/2005/11/21/vbscript-array-length/#comment-17717</guid>
		<description>You could always create a counter, loop thru the array &amp; increment as you go. It may be ugly but it works


Dim counter
For Each x in myArray 
 counter = counter + 1
Next</description>
		<content:encoded><![CDATA[<p>You could always create a counter, loop thru the array &amp; increment as you go. It may be ugly but it works</p>
<p>Dim counter<br />
For Each x in myArray<br />
 counter = counter + 1<br />
Next</p>
]]></content:encoded>
	</item>
</channel>
</rss>

