If you use the VB.NET Upgrade Wizard to convert this VB6 statement to VB.NET:
DateEcho.Caption = _
Format$(theDate, "MMMM d, yyyy")
The result is this VB.NET statement:
DateEcho.Text = CStr(theDate)
The VB.NET Upgrade Wizard doesn't even attempt to use Format! And it's not clear why because code that is substantially the same could have been used. The following code works just fine in VB.NET.
Dim theDate As Date
theDate = #12/25/2007#
DateEcho.Text = _
Format$(theDate, "MMMM d, yyyy")
This is just more evidence for my long-held position that when you upgrade a VB6 program to VB.NET, plan on rewriting your code manually. In this case, the Upgrade Wizard might not have used Format because they might have decided it was just too much complexity to handle in an automated conversion.
Explaining that complexity is the goal of this article!
The description of the Format function for VB6 is ...
Format(Expression, strFormat)
... where strFormat is a combination of format characters like "MMMM" for "long month" and "d" for "day" or perhaps a keyword expression like "Medium Time".
The description of the Format function in VB.NET is quite different. Instead of just telling you how to use it, they tell you what it is:
Public Shared Function Format( _
ByVal Expression As Object, _
Optional ByVal Style As String = "" _
) As String
The practical difference for day-to-day use between Format in VB6 and Format in VB.NET is mostly appearance. For example, Style is nearly identical with with the VB6 strFormat.
The VB.NET Format function is just shared code you can call. Some other slightly related functions in this same module are Split and Len. The Format function in VB.NET is part of the Microsoft.VisualBasic namespace and is intended to provide some compatibility with VB6.
Page 2 tells you how to get more with VB.NET!

