<?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>WinSoft.se &#187; Compile options</title>
	<atom:link href="http://www.winsoft.se/tag/compile-options/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.winsoft.se</link>
	<description>Development with focus on Visual Basic .NET</description>
	<lastBuildDate>Thu, 26 Jan 2012 19:28:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Compile options in VB9 &#8211; compare and infer</title>
		<link>http://www.winsoft.se/2008/12/compile-options-in-vb9-compare-and-infer/</link>
		<comments>http://www.winsoft.se/2008/12/compile-options-in-vb9-compare-and-infer/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 12:20:39 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 9]]></category>
		<category><![CDATA[Compile options]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=68</guid>
		<description><![CDATA[These options can also be set for all modules in the project settings window, or for each file in code. If the settings are in conflict, the setting written in code overrides the project setting. Option compare This option simply tells if strings will be compared case sensitive (option compare text) or binary (option compare [...]]]></description>
			<content:encoded><![CDATA[<p>These options can also be set for all modules in the project settings window, or for each file in code. If the settings are in conflict, the setting written in code overrides the project setting.</p>
<p><strong>Option compare</strong><br />
This option simply tells if strings will be compared case sensitive (option compare text) or binary (option compare binary). So, given that option compare is set to binary, A is set to False, otherwise True.</p>
<p><strong>Dim A As Boolean = (&#8220;ABC&#8221; = &#8220;abc&#8221;)</strong></p>
<p><strong>Option infer</strong><br />
This option can be on or off. When infer is set to on, you do not have to type out the data type of a variable when you are declaring it.</p>
<p>This code will make A an Integer, since it is initialized with a integer value, and B a Short, since it is initialized with a short integer value.</p>
<p><strong>Dim A = 1<br />
Dim B = 2S</strong></p>
<p>When option infer is set to off, you must type out the name of the datatype. Either way, the code is still type safe.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2008/12/compile-options-in-vb9-compare-and-infer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile options in VB9 &#8211; explicit and strict</title>
		<link>http://www.winsoft.se/2008/12/compile-options-in-vb9-explicit-and-strict/</link>
		<comments>http://www.winsoft.se/2008/12/compile-options-in-vb9-explicit-and-strict/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 12:19:42 +0000</pubDate>
		<dc:creator>Anders Hesselbom</dc:creator>
				<category><![CDATA[Visual Basic 9]]></category>
		<category><![CDATA[Compile options]]></category>

		<guid isPermaLink="false">http://www.winsoft.se/?p=66</guid>
		<description><![CDATA[Compile options can be set for all source code files at the same time in the project file, and they can be overridden in each file. If you want to override a compile option for file, just make sure that the compile option(s) are the first line(s) in the file, before any code. The compile [...]]]></description>
			<content:encoded><![CDATA[<p>Compile options can be set for all source code files at the same time in the project file, and they can be overridden in each file. If you want to override a compile option for file, just make sure that the compile option(s) are the first line(s) in the file, before any code. The compile options are option explicit, option strict, option compare and option infer. This post covers option explicit and option strict. </p>
<p><strong>Option explicit</strong><br />
This option can be on or off, and choosing anything but on is just silly. When option explicit is set to on, all variables have to be explicitly declared. Imagine a function with these two lines:</p>
<p><strong>X = 10<br />
Console.WriteLine(X)</strong></p>
<p>This will only compile if option explicit is set to off. And this is just stupid. All variables will be declared automatically at the first time they are referred to, and mistakes that normally would be caught by the compiler (like a misspell or a value assign of the wrong type) will be accepted by the compiler.</p>
<p><strong>Option strict</strong><br />
This option can be on or off, and you should have a really good reason for choosing anything but on. This has to do with type casting. When option strict is set to off, you can do implisive casting any way you like, just as long as the value fits in the destination variable. If you have the number five stored in a 32 bit integer variable, you can assign it to a 16 bit integer. It’s the same way with objects. You can assign an object to a less specific variable and back to a more specific. You will get a runtime exception if the target type is not suitable. When option strict is set to on, you can only assign values from more specific to less specific variables, without using explicit type casting. This will work independent on option strict:</p>
<p><strong>Dim X As Short = 10<br />
Dim Y As Integer = X</strong></p>
<p>This requires that option strict is set to off:</p>
<p><strong>Dim I As Integer = 4<br />
Dim S As Short = I</strong></p>
<p>And if you want to do the last operation and you are working with option strict set to on, you can do an explicit cast of the type:</p>
<p><strong>Dim I As Integer = 4<br />
Dim S As Short = CType(I, Short)</strong></p>
<p>In a way, working with option strict set to on is good, because that means that you have to prove that the code you’re writing is what you intend to do. That you have to actually do the cast, means that you know that you are doing something that (depending on the value of I) might fail.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.winsoft.se/2008/12/compile-options-in-vb9-explicit-and-strict/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

