 




<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The VBScript Network and Systems Administrator&#039;s Cafe &#187; Logical File</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/tag/logical-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator</link>
	<description></description>
	<lastBuildDate>Tue, 11 Oct 2011 18:36:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>VBScript Statements: Explanation of If&#8230; Then &#8230; Endif</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-if-then-endif/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-if-then-endif/#comments</comments>
		<pubDate>Wed, 21 May 2008 18:49:10 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[else]]></category>
		<category><![CDATA[If Then]]></category>
		<category><![CDATA[IF Then Else]]></category>
		<category><![CDATA[Logical File]]></category>
		<category><![CDATA[Then]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript Statements]]></category>
		<category><![CDATA[vbscriptstatements]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explaination-of-if-then-endif/</guid>
		<description><![CDATA[The If/Then/Else statement in VBScript is very similar to the Select Case statement, except it only normally allows for 2 possibilities in your condition.  Basically, the If/Then statement says&#8211; It is or it isn&#8217;t. It very useful for testing a specific value to see if it is equal to, greater than, or less than something [...]]]></description>
				<content:encoded><![CDATA[<p>The If/Then/Else statement in VBScript is very similar to the <a href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explaination-of-select-case/">Select Case statement</a>, except it only normally allows for 2 possibilities in your condition.  Basically, the If/Then statement says&#8211; <em>It is or it isn&#8217;t.</em></p>
<p>It very useful for testing a specific value to see if it is equal to, greater than, or less than something else and doing something based on the outcome of the condition. The statement always evaluates the expression based of if the condition is true. For example, this code would always run, because the condition would always be true:</p>
<p><font color="#0000ff">x=1<br />
if x=1 then<br />
     &#8216;do something<br />
Endif</font></p>
<p>While this code would never run:</p>
<p><font color="#0000ff">x=1<br />
if x&gt;1 then<br />
&#8216;do something<br />
endif</font></p>
<p>The else option is a useful tool as well, it applies to all other conditions should the if test expression(s) not be true. This allows for code to run under only certain situations, depending on the value of the expression:</p>
<p><font color="#0000ff">x=1<br />
if x=1 then<br />
&#8216;do something<br />
else<br />
&#8216;do something else for all other possibilities</font><font color="#0000ff"><br />
endif</font></p>
<p><font color="#000000">Optionally, there is a <strong>elseif</strong> component of the statement that can include another condition. However, if you start to need more than more than one of these a <a href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explaination-of-select-case/">select/case statement </a>is likely a better option. Consider this example:</font></p>
<p><font color="#0000ff"><br />
if x=1 then<br />
&#8216;do something<br />
elseif x=0<br />
&#8216; do something else<br />
elseif x=2<br />
&#8216; do another something else<br />
elseif x=3<br />
&#8216; do something completely different<br />
else<br />
&#8216;do something else for all other possibilities<font color="#0000ff"><br />
endif</font></font></p>
<p><font color="#0000ff"><font color="#0000ff"><font color="#0000ff"><font color="#000000">In this last case, the important thing to remember is the only part of the code that runs is the where the expression best fits and only <strong><em><u>ONE</u></em></strong> section is executed. </font></font></font></font></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-if-then-endif/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
