 




<?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; working with variables</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/tag/working-with-variables/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>Using special characters in VBScript strings</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/special-characters-in-vbscript-strings/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/special-characters-in-vbscript-strings/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 15:21:52 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[ASCII]]></category>
		<category><![CDATA[Special Characters]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[String manipulation]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[VBScipt]]></category>
		<category><![CDATA[working with variables]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/?p=107</guid>
		<description><![CDATA[I just realized I&#8217;ve been using Visual Basic String constants in my scripts with little to no explanation. We&#8217;ll rectify that situation right now! When dealing with strings in VBScript, you occasionally need to add formatting characters to a string, so that when it is displayed on the screen or in a file it looks [...]]]></description>
				<content:encoded><![CDATA[<p>I just realized I&#8217;ve been using Visual Basic String constants in my scripts with little to no explanation. We&#8217;ll rectify that situation right now! <img src='http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>When dealing with strings in VBScript, you occasionally need to add formatting characters to a string, so that when it is displayed on the screen or in a file it looks correct. If you know your ASCII chart you can certainly preform this with a <em>&#8220;&amp; chr(X) &amp;&#8221;.</em>However, if you don&#8217;t know what ASCII value a tab is (it&#8217;s 9) then you can simply use Visual Basic&#8217;s string constants in your scripts and have the added benefit if making it easier to read!</p>
<p>The constants and their meanings are listed below:</p>
<table border="0">
<tbody>
<tr>
<td>VBTab</td>
<td>A Tab character [Chr(9)]</td>
</tr>
<tr>
<td>VBCr</td>
<td>A carriage return [Chr(13)]</td>
</tr>
<tr>
<td>VBCrLf</td>
<td>A carriage return and line feed [Chr(13) + Chr(10)]</td>
</tr>
<tr>
<td>vbBack</td>
<td>A backspace character [Chr(8)]</td>
</tr>
<tr>
<td>vbLf</td>
<td>A linefeed [Chr(10)]</td>
</tr>
<tr>
<td>vbNewLine</td>
<td>A platform-specific new line character, either [Chr(13) + Chr(10)] or [Chr(13)]</td>
</tr>
<tr>
<td>vbNullChar</td>
<td>A null character of value 0 [Chr(0)]</td>
</tr>
<tr>
<td>vbNullString</td>
<td>A string of value 0 [no Chr code]; note that this is not the same as &#8220;&#8221;</td>
</tr>
</tbody>
</table>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/special-characters-in-vbscript-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A new found bug in VBScript that causes if then statements to return wrong comparisons (or is it?)</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-new-found-bug-in-vbscript-that-causes-if-then-statements-to-return-wrong-comparisons-or-is-it/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-new-found-bug-in-vbscript-that-causes-if-then-statements-to-return-wrong-comparisons-or-is-it/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 00:00:58 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[Integer]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[Variable Types]]></category>
		<category><![CDATA[variant]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[working with variables]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-new-found-bug-in-vbscript-that-causes-if-then-statements-to-return-wrong-comparisons-or-is-it/</guid>
		<description><![CDATA[In the past I&#8217;ve cautioned you on always initializing your variables and encouraged you to always declare your variable types, rather than using the default variant type in VBScript. I&#8217;ll be the first to admit I don&#8217;t follow my own advice in my examples! However, variants can be dangerous! Recently I had a situation where if [...]]]></description>
				<content:encoded><![CDATA[<p>In the past I&#8217;ve cautioned you on always initializing your variables and encouraged you to always declare your variable types, rather than using the default variant type in VBScript. I&#8217;ll be the first to admit I don&#8217;t follow my own advice in my examples! However, variants can be dangerous!</p>
<p>Recently I had a situation where if statements were returning completely not correct results and for the life of me I couldn&#8217;t figure it out! Here is an example that illustrates what was happening to me.</p>
<p><font color="#0000ff">one = 1<br />
two = 2<br />
three = 3<br />
OneBillion = 1000000000</font></p>
<p><font color="#0000ff">MyVar = inputbox(&#8220;Enter a number&#8221;)</font><font color="#0000ff">If one &lt; MyVar Then<br />
     WScript.Echo (one &amp; &#8221; is lessthan &#8221; &amp; MyVar)<br />
End If<br />
If two &lt; MyVar Then<br />
     WScript.Echo (two &amp; &#8221; is lessthan &#8221; &amp; MyVar)<br />
End If</font><font color="#0000ff"><font color="#0000ff">If three &lt; MyVar Then<br />
     WScript.Echo (three &amp; &#8221; is lessthan &#8221; &amp; MyVar)<br />
End If</font></font><font color="#0000ff"><font color="#0000ff">If OneBillion &lt; MyVar Then<br />
     WScript.Echo (OneBillion &amp; &#8221; is lessthan &#8221; &amp; MyVar)<br />
End If</font></p>
<p></font><font color="#000000">The basis of the problem is that I was taking input from a file that was a number&#8211; however I was reading the file and it was coming into the script and being used as a string by the variant variable. I then was comparing it to a number and the comparisons were not working 100% correctly. Check it out by entering several numbers into the script. Try entering 0, 1, 2, 3, and 1000000001.</font></p>
<p>The moral of the story here is to always cast your varables as a specific type or use the cint() function to convert your variant varables to numbers before doing number comparisons with a literal number and a variant variable that is supposed to contain a number.</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/a-new-found-bug-in-vbscript-that-causes-if-then-statements-to-return-wrong-comparisons-or-is-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VBScript Statements: Explanation of the Set Statement</title>
		<link>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-the-set-statement/</link>
		<comments>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-the-set-statement/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 22:00:48 +0000</pubDate>
		<dc:creator>Jerry Lees</dc:creator>
				<category><![CDATA[Objects]]></category>
		<category><![CDATA[set]]></category>
		<category><![CDATA[set command]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[VBScript Objects]]></category>
		<category><![CDATA[VBScript Statements]]></category>
		<category><![CDATA[working with objects]]></category>
		<category><![CDATA[working with variables]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-the-set-statement/</guid>
		<description><![CDATA[The set statement is used to assign any value to any type of variable. For the most part this command is optional. However, it needs to be used when you are assigning an object reference to a variable, such as when you use a variable to hold the return of a CreateObject function for later reference [...]]]></description>
				<content:encoded><![CDATA[<p>The set statement is used to assign any value to any type of variable. For the most part this command is optional. However, it needs to be used when you are assigning an object reference to a variable, such as when you use a variable to hold the return of a CreateObject function for later reference in your code.</p>
<p>An example of the set command would look like:</p>
<p><font color="#0000ff">Option explicit<br />
Dim objDictionary<br />
Set objDictionary = CreateObject(”Scripting.Dictionary”)</font></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/vbscript-systems-administrator/vbscript-statements-explanation-of-the-set-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
