<?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: For Next Behaviour</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2005/01/29/for-next-behaviour/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2005/01/29/for-next-behaviour/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/01/29/for-next-behaviour/#comment-6306</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Mon, 31 Jan 2005 10:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1000#comment-6306</guid>
		<description>&lt;p&gt;Dennis, Stephen,&lt;/p&gt;
&lt;p&gt;I think you&#039;ve convinced me... I&#039;ll stick to what I&#039;ve been doing, even though now it&#039;ll be for the right reasons!&lt;/p&gt;
&lt;p&gt;It was the debugging that got me in the end.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br&gt;
Rob&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Dennis, Stephen,</p>
<p>I think you&#8217;ve convinced me&#8230; I&#8217;ll stick to what I&#8217;ve been doing, even though now it&#8217;ll be for the right reasons!</p>
<p>It was the debugging that got me in the end.</p>
<p>Cheers,<br />
Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephen Bullen</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/01/29/for-next-behaviour/#comment-6304</link>
		<dc:creator>Stephen Bullen</dc:creator>
		<pubDate>Mon, 31 Jan 2005 09:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1000#comment-6304</guid>
		<description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;Personally, I use the &#039;variable&#039; approach for anything more than a fairly simple calculation. The reason is that it makes debugging *much* easier. When stepping through the code with the Locals Window visible, I can readily identify the bounds of loop (they&#039;re showing in the variable&#039;s values). That also gives me an opportunity to correct the calculation if anything&#039;s wrong.&lt;/p&gt;
&lt;p&gt;The same applies to With blocks, as trying to fix a complex calculation in a With statement requires a re-compile.&lt;/p&gt;
&lt;p&gt;It should also be noted that Do...Loop structures *do* evaluate the expression each time round.&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Stephen Bullen&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Rob</p>
<p>Personally, I use the &#8216;variable&#8217; approach for anything more than a fairly simple calculation. The reason is that it makes debugging *much* easier. When stepping through the code with the Locals Window visible, I can readily identify the bounds of loop (they&#8217;re showing in the variable&#8217;s values). That also gives me an opportunity to correct the calculation if anything&#8217;s wrong.</p>
<p>The same applies to With blocks, as trying to fix a complex calculation in a With statement requires a re-compile.</p>
<p>It should also be noted that Do&#8230;Loop structures *do* evaluate the expression each time round.</p>
<p>Regards</p>
<p>Stephen Bullen</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/01/29/for-next-behaviour/#comment-6282</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Sun, 30 Jan 2005 21:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1000#comment-6282</guid>
		<description>&lt;p&gt;Hi Dennis,&lt;/p&gt;
&lt;p&gt;Thanks for your feedback.&lt;/p&gt;
&lt;p&gt;The point of the example was to show that the end part of the for next statement is read just once.&lt;/p&gt;
&lt;p&gt;Not only does that apply to end portion, but the start portion too.&lt;/p&gt;
&lt;p&gt;Sub test()&lt;br&gt;
    Dim i As Long&lt;/p&gt;
&lt;p&gt;    For i = s To e&lt;br&gt;
        Debug.Print i&lt;br&gt;
    Next&lt;br&gt;
End Sub&lt;/p&gt;
&lt;p&gt;Function s() As Long&lt;br&gt;
    s = 1&lt;br&gt;
    MsgBox &quot;start&quot;&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;Function e() As Long&lt;br&gt;
    e = 10&lt;br&gt;
    MsgBox &quot;end&quot;&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;I do agree that if the calc is reused elsewhere, it makes sense to store it away than recalculate.&lt;/p&gt;
&lt;p&gt;However, as in the example in the post, the variable may only be used just once.&lt;/p&gt;
&lt;p&gt;In this case I would find the code cleaner and easier to maintain if that variable were not declared at all - no matter VBA / VB / .NET&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br&gt;
Rob&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi Dennis,</p>
<p>Thanks for your feedback.</p>
<p>The point of the example was to show that the end part of the for next statement is read just once.</p>
<p>Not only does that apply to end portion, but the start portion too.</p>
<p>Sub test()<br />
    Dim i As Long</p>
<p>    For i = s To e<br />
        Debug.Print i<br />
    Next<br />
End Sub</p>
<p>Function s() As Long<br />
    s = 1<br />
    MsgBox &#8220;start&#8221;<br />
End Function</p>
<p>Function e() As Long<br />
    e = 10<br />
    MsgBox &#8220;end&#8221;<br />
End Function</p>
<p>I do agree that if the calc is reused elsewhere, it makes sense to store it away than recalculate.</p>
<p>However, as in the example in the post, the variable may only be used just once.</p>
<p>In this case I would find the code cleaner and easier to maintain if that variable were not declared at all &#8211; no matter VBA / VB / .NET</p>
<p>Cheers,<br />
Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dennis Wallentin</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/01/29/for-next-behaviour/#comment-6278</link>
		<dc:creator>Dennis Wallentin</dc:creator>
		<pubDate>Sun, 30 Jan 2005 17:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1000#comment-6278</guid>
		<description>&lt;p&gt;When working with Excel from VB 6.0 or VB.NET/C# there is an advantage of using the &quot;variable&quot;-approach, especially if the information will be used for several purposes (same reason can be applied to VBA).&lt;/p&gt;
&lt;p&gt;On a personal note I find the &quot;variable&quot; approach to be much cleaner and make the life easier during maintance which is usually done long time ago after the original code was created.&lt;/p&gt;
&lt;p&gt;The only reason that would change my way of coding would be if You or someone else could proof that there will be an advantage of using the &quot;non-variable&quot; approach in respect to speed and performance.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br&gt;
Dennis&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>When working with Excel from VB 6.0 or VB.NET/C# there is an advantage of using the &#8220;variable&#8221;-approach, especially if the information will be used for several purposes (same reason can be applied to VBA).</p>
<p>On a personal note I find the &#8220;variable&#8221; approach to be much cleaner and make the life easier during maintance which is usually done long time ago after the original code was created.</p>
<p>The only reason that would change my way of coding would be if You or someone else could proof that there will be an advantage of using the &#8220;non-variable&#8221; approach in respect to speed and performance.</p>
<p>Kind regards,<br />
Dennis</p>
]]></content:encoded>
	</item>
</channel>
</rss>

