<?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: Validation Functions</title>
	<atom:link href="http://peltiertech.com/WordPress/validation-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://peltiertech.com/WordPress/validation-functions/</link>
	<description>PTS Excel Charts and Tutorials Blog</description>
	<lastBuildDate>Sat, 21 Nov 2009 04:01:08 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-12002</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Sat, 14 Mar 2009 17:31:47 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-12002</guid>
		<description>With every test you have an opportunity to define a piece of information to pass back to the calling routine. I don&#039;t think where you start makes much difference.</description>
		<content:encoded><![CDATA[<p>With every test you have an opportunity to define a piece of information to pass back to the calling routine. I don&#8217;t think where you start makes much difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Glancy</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-12000</link>
		<dc:creator>Doug Glancy</dc:creator>
		<pubDate>Sat, 14 Mar 2009 17:15:23 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-12000</guid>
		<description>I thought about this some more, and it seems like starting at False makes it easier to return the reasons that the function fails, either runtime or validation errors.</description>
		<content:encoded><![CDATA[<p>I thought about this some more, and it seems like starting at False makes it easier to return the reasons that the function fails, either runtime or validation errors.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11971</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Sat, 14 Mar 2009 03:54:30 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11971</guid>
		<description>Doug -

I&#039;l wait for Bob&#039;s take on this, but I think it&#039;s a kind of half-empty, half-full situation. I don&#039;t think there&#039;s any real reason to do it one way or the other. It just makes sense in my mind not to claim success until you&#039;ve ruled out failure.</description>
		<content:encoded><![CDATA[<p>Doug -</p>
<p>I&#8217;l wait for Bob&#8217;s take on this, but I think it&#8217;s a kind of half-empty, half-full situation. I don&#8217;t think there&#8217;s any real reason to do it one way or the other. It just makes sense in my mind not to claim success until you&#8217;ve ruled out failure.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Glancy</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11961</link>
		<dc:creator>Doug Glancy</dc:creator>
		<pubDate>Sat, 14 Mar 2009 00:21:11 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11961</guid>
		<description>I notice that Bob sets the function to true at the beginning and changes the value to false in the error handler, whereas Jon explicitly sets it to false and uses Goto to break out of the function before it turns true if there&#039;s an error.  I&#039;m used to doing it Jon&#039;s way (although I&#039;ve stopped explicitly setting the function to false).  What are the advantages of your way, Bob?</description>
		<content:encoded><![CDATA[<p>I notice that Bob sets the function to true at the beginning and changes the value to false in the error handler, whereas Jon explicitly sets it to false and uses Goto to break out of the function before it turns true if there&#8217;s an error.  I&#8217;m used to doing it Jon&#8217;s way (although I&#8217;ve stopped explicitly setting the function to false).  What are the advantages of your way, Bob?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11930</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Fri, 13 Mar 2009 10:52:58 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11930</guid>
		<description>Public Function MyFunction would have sounded redundant even if I had noticed (&lt;em&gt;O Captain, my Captain&lt;/em&gt;), but it&#039;s fixed now.

The code uses html tags (&lt;pre&gt; &lt;/pre&gt;), none of the square bracket tags, because I really don&#039;t like how any of those plugins work. Until I get four hundred comments a day, it&#039;s not too burdensome to fix it myself. Those of us with OCD have lots of energy for that sort of thing.</description>
		<content:encoded><![CDATA[<p>Public Function MyFunction would have sounded redundant even if I had noticed (<em>O Captain, my Captain</em>), but it&#8217;s fixed now.</p>
<p>The code uses html tags (&lt;pre&gt; &lt;/pre&gt;), none of the square bracket tags, because I really don&#8217;t like how any of those plugins work. Until I get four hundred comments a day, it&#8217;s not too burdensome to fix it myself. Those of us with OCD have lots of energy for that sort of thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11929</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Fri, 13 Mar 2009 10:45:57 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11929</guid>
		<description>Thank you for tidying up my code, presumably there are tags to do that, what are they [code]...[/code]?

You didn&#039;t spot that I missed the Function keyword in the Function signature though </description>
		<content:encoded><![CDATA[<p>Thank you for tidying up my code, presumably there are tags to do that, what are they [code]...[/code]?</p>
<p>You didn&#8217;t spot that I missed the Function keyword in the Function signature though</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11916</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Fri, 13 Mar 2009 01:36:33 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11916</guid>
		<description>Bob -

You&#039;re right, I should start showing ByVal and ByRef. In fact, I should probably start using them in my own code. I&#039;ll start tomorrow.</description>
		<content:encoded><![CDATA[<p>Bob -</p>
<p>You&#8217;re right, I should start showing ByVal and ByRef. In fact, I should probably start using them in my own code. I&#8217;ll start tomorrow.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bob Phillips</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11913</link>
		<dc:creator>Bob Phillips</dc:creator>
		<pubDate>Thu, 12 Mar 2009 23:24:03 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11913</guid>
		<description>I think that all good experienced developers, of which we all know that you are one, should always explicitly declare whether a parameter is being passed ByVal or ByRef. Helping to spread good practices is part of the role IMO .

As I mentioned in DDoE, I have gotten into the habit of rarely passing a function result back as a function result, I rather pass all results back (I often require more than one, even if only a non-critical return code in addition to the functional value) as ByRef parameters. My function then passes back whether it was a critical failure or not. For example

&lt;pre class=&quot;vbasmall&quot;&gt;Public Function MyFunction( _
	ByVal input As String, _
	ByRef output1 As Long, _
	ByRef output2 As String) As Boolean
	
	MyFunction = True
	On Error Goto MyFunction_err
	
	&#039;some code that does stuff and sets up output1 and output2
	
MyFunction_exit:
	Exit Function
	
MyFunction_err:
	MyFunction = False
	Resume MyFunction_exit
End Function
&lt;/pre&gt;
 &lt;br /&gt;
and call it like so

&lt;pre class=&quot;vbasmall&quot;&gt;	If Not MyFunction(&quot;Bob&quot;, mpAge, mpSex) then
	
		&#039;handle this error
		Exit Function
	End IF
	
	&#039;now process the mpAge and mpSex variables returned
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>I think that all good experienced developers, of which we all know that you are one, should always explicitly declare whether a parameter is being passed ByVal or ByRef. Helping to spread good practices is part of the role IMO .</p>
<p>As I mentioned in DDoE, I have gotten into the habit of rarely passing a function result back as a function result, I rather pass all results back (I often require more than one, even if only a non-critical return code in addition to the functional value) as ByRef parameters. My function then passes back whether it was a critical failure or not. For example</p>
<pre class="vbasmall">Public Function MyFunction( _
	ByVal input As String, _
	ByRef output1 As Long, _
	ByRef output2 As String) As Boolean

	MyFunction = True
	On Error Goto MyFunction_err

	'some code that does stuff and sets up output1 and output2

MyFunction_exit:
	Exit Function

MyFunction_err:
	MyFunction = False
	Resume MyFunction_exit
End Function
</pre>
<p> <br />
and call it like so</p>
<pre class="vbasmall">	If Not MyFunction("Bob", mpAge, mpSex) then

		'handle this error
		Exit Function
	End IF

	'now process the mpAge and mpSex variables returned
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11909</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Thu, 12 Mar 2009 22:11:22 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11909</guid>
		<description>There is a difference in how objects behaved when passed ByVal or ByRef, and it&#039;s explained in &lt;a href=&quot;http://www.windowsdevcenter.com/pub/a/oreilly/windows/ron/objects.html&quot; rel=&quot;nofollow&quot;&gt;Objects and ByVal or ByRef &#124; O&#039;Reilly Media&lt;/a&gt;. But it took a complex example to show this difference. For the most part, in simple cases, there is no measurable difference.</description>
		<content:encoded><![CDATA[<p>There is a difference in how objects behaved when passed ByVal or ByRef, and it&#8217;s explained in <a href="http://www.windowsdevcenter.com/pub/a/oreilly/windows/ron/objects.html" rel="nofollow">Objects and ByVal or ByRef | O&#8217;Reilly Media</a>. But it took a complex example to show this difference. For the most part, in simple cases, there is no measurable difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://peltiertech.com/WordPress/validation-functions/comment-page-1/#comment-11901</link>
		<dc:creator>JP</dc:creator>
		<pubDate>Thu, 12 Mar 2009 18:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=1672#comment-11901</guid>
		<description>I believe you&#039;re correct Jon, but I can&#039;t find the page in PED that mentions it. I only found the bit on page 63 that talks about ByRef and ByVal. But I do believe it&#039;s mentioned later in the text.

I like the boolean approach best, especially for the straightforward routines that either should work or completely fail. Then just test for that in your calling procedure.</description>
		<content:encoded><![CDATA[<p>I believe you&#8217;re correct Jon, but I can&#8217;t find the page in PED that mentions it. I only found the bit on page 63 that talks about ByRef and ByVal. But I do believe it&#8217;s mentioned later in the text.</p>
<p>I like the boolean approach best, especially for the straightforward routines that either should work or completely fail. Then just test for that in your calling procedure.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
