Visual Basic Blog

A group blog from members of the VB team

The many cases of ByRef

One of the overlooked or simply misunderstood features of the VB language is calling a function which has a ByRef parameter.  Most languages support only a single method of passing parameters by reference [1], that is the scenarios directly supported by the CLR.  The CLR has a lot of restrictions on the type of values it supports for...

Fun With Dynamic Objects (Doug Rothaus)

A while back, I remember being asked if there was a simple way to expose a source XML document as an object with properties. That is, if the root XML element had a child element <Name>Doug</Name>, then the object would have a Name property that was a string and returned “Doug”. The catch was that the XML document did ...

There’s No Such Thing As Too Much Euchre! (Matt Gertz)

“Oh, no!”  I hear you cry, “not another blog about Euchre!”Well, I do like the game, to be sure.  But, more importantly, the Euchre scenario enables me to try out any new technologies on a reasonably complex problem (using Visual Basic, of course).  It’s my way of checking out our product to make ...

Hidden Gems in VB2010 – Serializing Objects that Raise Events (Jonathan Aneja)

By now you've likely heard about the major new features coming in VB 2010, but there's also a number of smaller additions in the language and IDE that might not be as readily noticeable.  "Hidden Gems" will be a multi-part series where we'll explore some of these smaller enhancements.  First up - serialization! Let’s say ...

Spot the Bug! – The Key to using Anonymous Types (Jonathan Aneja)

This one’s going to be long, but for those of you who’ve felt the first 3 in this series were too easy I promise this one’s tougher J. Let’s say you want to list all the customers from a table in a ComboBox, and update the UI based on which one is selected.  To do this we’ll need to bring back two fields...

Spot the Bug! – Is it in VB or XAML? (Jonathan Aneja)

What’s wrong with the following WPF code?   Class Window1     Sub OK_Click(sender As Object, e As RoutedEventArgs) Handles OK.Click       MsgBox("Button Clicked")   End Sub   End Class   <Window x:Class="Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/...

Linking Zune media items with LinQ, Part 2 (Matt Gertz)

In this post, I’ll continue on with coding the new playlist shuffler.  If you haven’t read part 1 yet, I highly recommend it so that this post will make more sense. JCode for the controls (continued)The Title TextBoxWhen the title changes, we’ll want to indicate that the playlist has changed, and we’ll want to ...

Linking Zune media items with LinQ, Part 1 (Matt Gertz)

Way back in October 2007, I wrote up a few posts (here and here) on my experiments with the Windows Media Player object model.  The problem I was trying to solve was that, when I had a playlist set to “shuffle,” WMP would break up songs that should always play together (for example, Jackson Browne’s “The Load-Out&...

Spot the Bug! – Much Ado about Nothing… (Jonathan Aneja)

Microsoft has this neat mailing list called “Spot the Bug” where developers can send interesting snippets of code that look correct but actually have subtle bugs in them.  The puzzles are a lot of fun and I’ve always thought it’d be a fun thing to try here on the team blog.  Over the past year or so I’ve been keeping a list...