Microsoft Developer Conference and VSLive Starting Next Week
Friday February 20, 2009
In an article I'm working on, I use what is called the "ternary operator" - a new feature in VB9 - Visual Basic.NET 2008. The syntax is illustrated by this example:
Dim myResult As String = _
If(1 > 2, "Less Than", "Or Not")
This is documented in the official language reference page for VB.NET ... if you know where to find it. But other than that, it's hard to find any information about it. The "Help" pages don't have a thing about it. (Or, at least, I couldn't find it.)
For the most part, the only place you can actually find real information about the explosion of new features is presentations by Microsoft gurus. Check out this list of new features in VB9:

The joint Microsoft Developer Conference and VSLive conference will be held in San Francisco starting next week. This is one of those places where you will have a chance learn the new new stuff now coming out in the next release. I plan on blogging from the floor!
If you can make it, you might want to download my Glossary of VSLive Buzzwords to help steer yourself to the right session for what you're doing!
New "Programmer" Site from the UK!
Sunday February 15, 2009
Mike James, editor of the UK based VSJ print magazine, is starting up his own "programmer" web site called, I-Programmer. (It reminds me of Isaac Asimov's science fiction classic, I Robot.)
In a home page launch article, Mike tells us that he decided "programmer" hits the right note for how he feels about what he does. Not "systems analyst" or "developer" or "computer scientist".
Programmer!
Since the site has only been on the web for a month, Mike says content is still "a bit thin." But everybody likes to see new things develop and grow so I thought my readers might like to check in on Mike and see how his site is doing.
I-Programmer
Relaxed Delegates in VB.NET 2008
Saturday February 7, 2009
I recently republished my article showing how to use delegates in VB.NET: Using Delegates in Visual Basic .NET for Runtime Flexibility. (In fact, I expanded that article after the newsletter went out last week. So there's more there now than there was a few days ago.)
I mention in that article that event handling in VB.NET is done through the use of delegates. In VB.NET 2008, there's an interesting new flexibility called "relaxed delegates". Here's how that works.
A delegate must match the signature (the parameter list) of the subroutine or function it addresses. In other words, if you declare a delegate like this:
Delegate Function myDel(ByVal a As Integer) As Integer
Then you have to assign a subroutine that has the same signature such as:
Function aFunc(ByVal x As Integer) As Integer
But the VB.NET 2008 compiler will add code for the correct signature if you leave it out (or if a conversion is required). So, aFunc above could be coded:
Function aFunc(ByVal x)
This has practical benefits in making your code more flexible in some situations, but another effect is that you can delete the parameter list entirely on event subroutines if you're not using them. So, instead of this:
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
You're now only required to code this:
Private Sub Button1_Click() _
Handles Button1.Click
There's no advantage except the avoidance of extra text in your source code. But it does make it slightly more readable.
Find the Line Number in a TextBox
Sunday February 1, 2009
A reader asked the question, "How can I find the line number of a line of text in a TextBox control?"
Here's what I came up with:
Private Sub TextBox1_MouseClick( ...
lblCursorLoc.Text = _
"Line Number: " & _
(Math.Round(( _
Cursor.Position.Y - Me.Location.Y - _
TextBox1.Location.Y - 36) / 13)) _
.ToString
End Sub
The problem with this solution is that the numbers 36 and 13 are "magic numbers" that have to be determined experimentally. (36 relates to the size of the heading of the form. 13 relates to the size of the font being used.)
Anybody know a better way?