<?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>Tim Van Wassenhove &#187; Visual Basic</title>
	<atom:link href="http://www.timvw.be/category/information-technology/visual-basic/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timvw.be</link>
	<description>The journey of a thousand miles begins with one step.</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:07:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Instruct T4 to use C# v3.5</title>
		<link>http://www.timvw.be/instruct-t4-to-use-c-v3-5/</link>
		<comments>http://www.timvw.be/instruct-t4-to-use-c-v3-5/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 08:05:33 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1248</guid>
		<description><![CDATA[Consider this simple T4 template: &#60;# for (var i = 0; i &#60; 10; ++i) { WriteLine(&#34;hello&#34;); } #&#62; Trying to build the project results in a compilation error because &#8216;var&#8217; is an unknown type. A bit of research learned me that i should instruct the processor to use a specific c# version like this: [...]]]></description>
			<content:encoded><![CDATA[<p>Consider this simple T4 template:</p>

<pre class="brush: xml;">&lt;# for (var i = 0; i &lt; 10; ++i) { WriteLine(&quot;hello&quot;); } #&gt;</pre>

<p>Trying to build the project results in a compilation error because &#8216;var&#8217; is an unknown type. A bit of research learned me that i should instruct the processor to use a specific c# version like this:</p>

<pre class="brush: xml;">&lt;#@ template language=&quot;C#v3.5&quot; inherits=&quot;Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation&quot;  #&gt;
&lt;# for (var i = 0; i &lt; 10; ++i) { WriteLine(&quot;hello&quot;); } #&gt;</pre>

<p>Problem solved <img src='http://www.timvw.be/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/instruct-t4-to-use-c-v3-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Access a control by name</title>
		<link>http://www.timvw.be/access-a-control-by-name/</link>
		<comments>http://www.timvw.be/access-a-control-by-name/#comments</comments>
		<pubDate>Sat, 25 Feb 2006 00:52:01 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Visual Basic]]></category>

		<guid isPermaLink="false">http://www.timvw.be/access-a-control-by-name/</guid>
		<description><![CDATA[I know a mathematician that can do magic with stats. That&#8217;s also the reason why he works at Eurostat. He&#8217;s automating a lot of his work by programming in Visual Basic for Applications. He asked me if i wanted to look at his code because he had the feeling there was a smell. Here are [...]]]></description>
			<content:encoded><![CDATA[<p>I know a mathematician that can do magic with stats. That&#8217;s also the reason why he works at <a href="http://epp.eurostat.cec.eu.int/portal/page?_pageid=1090,30070682,1090_33076576&#038;_dad=portal&#038;_schema=PORTAL">Eurostat</a>. He&#8217;s automating a lot of his work by programming in <a href="http://msdn.microsoft.com/isv/technology/vba/default.aspx">Visual Basic for Applications</a>. He asked me if i wanted to look at his code because he had the feeling there was a smell. Here are a couple lines:</p>
<pre class="brush: vb;">
With SomeForm
 .txtJanvier60.Value = vaData1(1, 2)
 .txtFevrier60.Value = vaData1(1, 3)
 .txtJanvier61.Value = vaData1(1, 2)
 .txtFevrier61.Value = vaData1(1, 3)
 ...
 .txtJanvier70.Value = vaData1(1, 2)
 .txtFevrier70.Value = vaData1(1, 3)
End With
</pre>
<p>It took me 5 minutes to search the web and change his code as following:</p>
<pre class="brush: vb;">
Dim months(1) as String
months(0) = &quot;Janvier&quot;
months(1) = &quot;Fevrier&quot;

With SomeForm
 For i = 60 to 70
  For j = 0 to UBound(months)
   .Controls(&quot;txt&quot; &amp; months(j) &amp; CStr(i)).Value = vaData1(1, j + 2)
  Next j
 Next i
End With
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/access-a-control-by-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing selected items from a ListBox</title>
		<link>http://www.timvw.be/removing-selected-items-from-a-listbox/</link>
		<comments>http://www.timvw.be/removing-selected-items-from-a-listbox/#comments</comments>
		<pubDate>Thu, 16 Feb 2006 00:53:39 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://www.timvw.be/removing-selected-items-from-a-listbox/</guid>
		<description><![CDATA[Today i was experimenting with a couple of windows controls. For some reason i wasn&#8217;t able to remove the selected items from a ListBox. Here is the code that didn&#8217;t work: For Each index As Integer = ListBox1.SelectedIndices ListBox2.Items.Add(ListBox1.Items(index)) ListBox1.Items.Remove(index) End For The problem is that when you remove an item from the collection the [...]]]></description>
			<content:encoded><![CDATA[<p>Today i was experimenting with a couple of windows controls. For some reason i wasn&#8217;t able to remove the selected items from a <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistboxmemberstopic.asp">ListBox</a>. Here is the code that didn&#8217;t work:</p>
<pre class="brush: vb;">
For Each index As Integer = ListBox1.SelectedIndices
  ListBox2.Items.Add(ListBox1.Items(index))
  ListBox1.Items.Remove(index)
End For
</pre>
<p>The problem is that when you remove an item from the collection the indices change. Here is a possible solution:</p>
<pre class="brush: vb;">
Dim index As Integer = ListBox1.SelectedIndex
While index &lt;&gt; -1
  ListBox2.Items.Add(ListBox1.Items(index))
  ListBox1.Items.Remove(index)
  index = ListBox1.SelectedIndex
End While
</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/removing-selected-items-from-a-listbox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
