<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>VB 10 thoughts (part 3)</title><link>http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx</link><description>More language thoughts for VB10 (see part1 and part2 for earlier posts) Delegate combining and removing syntax Today in VB if you write a Custom Event handler, you have to write some really long winded code to combine and remove delegates, such as : Custom</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: VB 10 thoughts (part 3)</title><link>http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx#1243639</link><pubDate>Fri, 12 Oct 2007 00:50:17 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1243639</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;Hi Paul,&lt;/p&gt;
&lt;p&gt;The problem with DefaultValue attribute is if you pass it an enum it compiles using the DefaultValue(Integer) constructor. &amp;nbsp;As such winforms doesn’t recognize the default value *properly*. &amp;nbsp;The bug is more o nthe winforms side of things, but being able to CObj in the attribute would address this; that is the language features would let us work around bugs in frameworks &amp;lt;g&amp;gt;.&lt;/p&gt;
&lt;p&gt;Here's some sample code :&lt;/p&gt;
&lt;p&gt;Public Class UserControl1&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Private m_FooProp As Foo = Foo.Baz&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;lt;System.ComponentModel.DefaultValue(Foo.Baz)&amp;gt; _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Public Property FooProp() As Foo&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;Get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Return m_FooProp&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Get&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;Set(ByVal value As Foo)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m_FooProp = value&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;End Set&lt;/p&gt;
&lt;p&gt; &amp;nbsp; End Property&lt;/p&gt;
&lt;p&gt;End Class&lt;/p&gt;
&lt;p&gt;Public Enum Foo&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Bar&lt;/p&gt;
&lt;p&gt; &amp;nbsp; Baz&lt;/p&gt;
&lt;p&gt;End Enum&lt;/p&gt;
&lt;p&gt;Note that when you reset the value on the winforms designer the value is still written in the initialize component section. To get it to work correctly you need to use this overload:&lt;/p&gt;
&lt;p&gt;&amp;lt;System.ComponentModel.DefaultValue(GetType(Foo), &amp;quot;1&amp;quot;)&amp;gt; _&lt;/p&gt;
&lt;p&gt;Note how the integer value had to be presented as a string. &amp;nbsp;In C# the original code works because they compile it to DefaultValue(Object) instead of DefaultValue(Integer)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1243639" width="1" height="1"&gt;</description></item><item><title>re: VB 10 thoughts (part 3)</title><link>http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx#1243597</link><pubDate>Fri, 12 Oct 2007 00:14:54 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1243597</guid><dc:creator>Paul Vick</dc:creator><description>&lt;p&gt;On #13, we still don't allow CObj, but I believe we did fix the enum problem (I think it had to do with weird overloading rules and conversions). The following code compiles fine:&lt;/p&gt;
&lt;p&gt;Enum Foo&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Bar&lt;/p&gt;
&lt;p&gt;End Enum&lt;/p&gt;
&lt;p&gt;&amp;lt;System.ComponentModel.DefaultValue(Foo.Bar)&amp;gt; _&lt;/p&gt;
&lt;p&gt;Class Baz&lt;/p&gt;
&lt;p&gt;End Class&lt;/p&gt;
&lt;p&gt;Are there other cases?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1243597" width="1" height="1"&gt;</description></item><item><title>re: VB 10 thoughts (part 3)</title><link>http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx#1241690</link><pubDate>Tue, 09 Oct 2007 00:03:08 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1241690</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;Jonathan, they aren't necessarily instance variables. If you use Static in a Shared method it is Shared across all instances. So the lifetime (instance versus non instance) is controlled by the surrounding block.&lt;/p&gt;
&lt;p&gt;But back to the main issue: people do find &amp;quot;static&amp;quot; confusing. &amp;nbsp;The only sense of the terminology is to mean the same as Shared does in VB. As Bob put it, the variable is persistant. &amp;nbsp;That is it is &amp;quot;Shared&amp;quot;. &amp;nbsp;If the method is an instance method the variable is shared amongst all calls to the method from that instance; if the method is Shared, then the variable is Shared amongst all calls to that method from all instances.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1241690" width="1" height="1"&gt;</description></item><item><title>re: VB 10 thoughts (part 3)</title><link>http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx#1240628</link><pubDate>Mon, 08 Oct 2007 17:41:38 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1240628</guid><dc:creator>Bob Bingham</dc:creator><description>&lt;p&gt;How about &amp;quot;Persistant&amp;quot;? &amp;nbsp;Or is that Persistent? &amp;nbsp;Oh well, the IDE will type it out for us bad spellers. ;)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1240628" width="1" height="1"&gt;</description></item><item><title>re: VB 10 thoughts (part 3)</title><link>http://msmvps.com/blogs/bill/archive/2007/10/06/vb-10-thoughts-part-3.aspx#1239193</link><pubDate>Mon, 08 Oct 2007 04:16:23 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1239193</guid><dc:creator>Jonathan Allen</dc:creator><description>&lt;p&gt;I have to disagree with you on item 3. I think &amp;quot;Shared&amp;quot; would be misleading because they are instance variables, not class-wide variables.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1239193" width="1" height="1"&gt;</description></item></channel></rss>