Using Namespaces - Namespaces keep VB.NET organized
Tim Patrick's Programming Visual Basic 2008
It's a fun read!
Here's another review hot on the heels of my review of Murach's latest VB.NET book (below). I thought these two books were an interesting contrast to each other.
- Patrick:
It's full of humor and interesting things about Visual Basic.
- Murach:
It's a structured and serious book focused on the goal of learning!
- Patrick:
It packs an amazing amount of information into a reasonably sized book.
- Murach:
It's sized to allow a comprehensive and thorough coverage of the subject.
- Patrick:
It's written by a genuine VB guru and published by O'Reilly - a major technical book publisher.
- Murach:
Murach is a highly specialized publisher of just one kind of book: books that help you learn software. Their use of salaried in-house writers give Murach the ability to publish books that are consistent and quality controlled
In fact, there are only two things that are the same:
- They both use a single project that's developed throughout the book to illustrate the programming concepts.
- They're both focused on VB.NET 2008.
ASP.NET 3.5 with VB 2008
The event you've been waiting for! Murach has published:

Ta Da! ... ASP.NET 3.5 with VB 2008
Well ... Maybe it's not quite that big an event in your life, but Murach's books are still pretty neat.
In fact, Murach's books are unique in the world of technical publishing and are perfectly suited for the targeted goal of learning and training. If you want to learn about how to build web pages with Visual Basic .NET, this book will do the job. My review covers their new ASP.NET 3.5 with VB 2008 book, including what's right and what's wrong.
Visual Studio 2008 Service Pack 1 Available!
(Well ... It is if you're a first class customer.)
Microsoft announced the availability of Visual Studio 2008 SP1 today (August 12). In addition to improvements in developer support, there's also a .NET Framework 3.5 SP1 that offers it's own slate of upgrades, including, "Performance increases between 20-45% for WPF-based applications – without having to change any code." (According to Microsoft.) (Why didn't they call it .NET Framework 3.6? The mind of a Microsoft marketing flake is unfathomable.)
You can read about the goodness packed into these two upgrades here. But, unless you are an MSDN subscriber (read: $$$$$) you can't download them. MSDN subscribers only, thank you so very much. A quote from the MSDN page at Microsoft:
"If you were an MSDN Subscriber, you would be able to initiate downloads of select products directly from here."
I wonder how long it will take for these to become available to the rest of us?
Dividing people into classes and delivering first class service to some and second class service to others seems to me to be a loser way to run a company. But what do I know? I graduated from Engineering.
NewLine - For All Platforms
A lot of us code vbCrLf at the end of a string when we want to move to a new line in the output.
MsgBox( _
"This is a message" _
 & NewLine & _
"on two lines.")
The "CrLf" stands for "carriage return, line feed" and is compiled into hex 0D & 0A. It's been the way I've programmed it for ages. For Windows platforms, that's not a problem. But if there's a chance that your code will run on another platform, you probably want to use Environment.vbNewLine. There are .NET ports for non-Windows environments, such as Mono.
The reason is that for some of these other environments, CrLf isn't a "new line". The Microsoft doc states that:
"The property value of NewLine is a constant customized specifically for the current platform and implementation of the .NET Framework."
Note that Microsoft also provides a different NewLine in the namespace Microsoft.VisualBasic.ControlChars. This code ...
Imports _
Microsoft.VisualBasic.ControlChars
Public Class Form1
Private Sub Button1_Click( ...
MsgBox( _
"This is a message" _
& NewLine & _
"on two lines.")
End Sub
End Class
... will give you a CrLf and not a platform independant value. (But then, the Imports for Microsoft.VisualBasic.ControlChars would probably fail on another platform anyway.)
Char Array "Unexpected Results"
I just spent a few hours of debugging effort and at the end, I discovered something that might be of use to someone else. It's not a bug. That is, if you took the time to report it to Microsoft, they wouldn't admit it's a bug. But after reading a lot of pages at MSDN, I happened to discover this on one of them:
"Null characters (equivalent to Chr(0)) in the string lead to unexpected results when using the string. The null character will be included with the string, but characters following the null character will not be displayed in some situations."
"Some situations" ??? What situations? Isn't programming supposed to be a precise activity. We're not supposed to have to guess about what will happen.
Here's the code I was working on. To code along with me, create a standard Windows application with two TextBox components (InputString and OutputString - set Multiline to True) and a Button to kick off the code.
Private Sub ReformatString_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles ReformatString.Click
Dim InCharArray() As Char = _
CType(InputString.Text, Char())
Dim OutCharArray(19) As Char
Dim OutStringBuilder As New StringBuilder
Dim InIndex As Integer = 0
Do While InIndex < InCharArray.Length - 20
Array.Copy( _
InCharArray, InIndex, OutCharArray, 0, 20)
OutStringBuilder.AppendLine( _
New String(OutCharArray))
InIndex += 20
Loop
OutputString.Text = OutStringBuilder.ToString
End Sub
This works. It reformats the string as a 20 character column. (The last few chars are skipped, but that's not the point here.)
My error (Yes, I did create the problem with a coding error initially.) was to code:
Array.Copy( _
InCharArray, InIndex, OutCharArray, 0, 19)
The effect of this was to leave a null character in the last element of OutCharArray. And the effect of that was to break:
- StringBuilder - VB reported the correct length but not the content of the resulting StringBuilder object. Nothing after the null character could be accessed or displayed.
But more surprising ...
- Debug.Write and Console.Write - I even found that single step mode gave different results than running the code with breakpoints! With no code changes! This added hours to my debugging effort!
All for getting one index number wrong.
The ContextMenuStrip Visual Basic Control
The ContextMenuStrip Visual Basic control is a little known example of the new generation of controls available in Visual Basic .NET. This article is a complete explanation to help you learn to use it. ... Read More!
WPF - A New Direction for GUI's
The next revolution in the software foundation for Microsoft's architecture is here. It's called WPF - Windows Presentation Foundation.
This is no minor fix. It's a full-scale new direction that will become the mainstream way to program your application. It's available now and now is the time to start learning it.
Some of the main features:
- Design is separate from coding.
Right now, the programmer does most of the design because it's all done in one step. WPF features an XML based declarative design called "XAML". Instead of dragging and dropping components onto forms, you build an XML file that "declares" what the design will look like. (VB.NET 2008 has "drag and drop" tools that make the process somewhat similar, but the end result is still a XAML file.) The application code doesn't depend on what the design looks like and can be done independently.
- The interface is a vector display instead of a raster display.
Instead of 1024 by 768 small dots (the most common resolution - your monitor may be different), graphics are created by drawing lines, called vectors, for each and every thing that appears on the screen. It may seem like it's more complicated (and, in some ways, it is) but consider these advantages: - Hardware graphics acceleration (that is, the hot new video cards) can do the job using the new DirectX technology used for games. That isn't possible with raster graphics.
- Images are scalable. A 500 percent image still looks good.
- A vector image can be converted into a raster image, but the reverse isn't possible.
- And, of course, there are scads of new, cool, components in WPF!
Because most of WPF is the new XAML coding, there's not a lot out there that addresses the Visual Basic programmer's questions. There is now ... A First Introduction to WPF and XAML for Visual Basic Programmmers
VB.NET Solution Explorer
A home for all your project files
An About Visual Basic reader just sent me this comment:
-----------
It may be obvious, but if I store a Word 2007 ".docx" file in the same folder as are stored the Form.vb files for a VB 2008 project, and then click on "Refresh", the .docx file duly appears in the list of accessible objects.
And, mirabile dicu, if I (double)click on it in that selfsame list, it opens ... in Word 2007!!!
By golly, someone did something correctly!
It's certainly one way of maintaining concurrent documentation.
-----------
Very good point! But it goes well beyond that.
A lot of people forget that Microsoft designed Visual Studio to be a complete development environment for all kinds of files. Common text files are one of the file types that you can "Add" right from the Solution Explorer menu.
But you can create any file type in the solution and VB.NET will let you manage it inside Solution Explorer. Not only Word, Excel, and other Microsoft products, but purely proprietary types will open with the program specified by their file extension.
Some file types, like XML and HTM, can be edited with VB.NET support including Intellisense and error correction.
Sams Teach Yourself Visual Basic 2008 in 24 Hours

This new member of the "24 Hours" series from Sams marches through Visual Basic like clockwork. It's a great introduction for anyone who hasn't programmed before and it would work well as the text for a beginning programming class. Experienced programmers will find that there isn't much here for them. The new features in VB 2008 are largely missing as well.

