| You are here: | About>Computing & Technology>Visual Basic> Using VB.NET> Formatting Strings, Numbers, and Other Objects |
![]() | Visual Basic |
Formatting Strings, Numbers, and Other ObjectsNov 3 2007 Format includes a lot of options!In an earlier article, I used the VB.NET 2005 Upgrade Wizard to convert this VB6 statement to VB.NET: DateEcho.Caption = _ The result was this VB.NET statement: DateEcho.Text = CStr(theDate) Much to my surprise, the VB.NET Upgrade Wizard didn't even attempt to use Format! And it's not clear why because identically the same code could have been used. The following code works just fine in VB.NET: Dim theDate As Date This is just more evidence for my long-held position that when you upgrade a VB6 program to VB.NET, plan on rewriting a lot of your code manually. The Upgrade Wizard might not have used Format because there are so many options that they might have decided it was just too much complexity to handle in an automated conversion. 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 Visual Basic "Help" system can give you a complete list. Search for "format function" for VB6 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( _ The difference in Microsoft's formal description between VB6 and VB.NET is mostly appearance. Style is nearly identical with strFormat. The VB.NET Format function is just code you can call in a VB.NET library, the Strings module. In other words, the Strings module is just a bag of code supplied by Microsoft, not a formal object. For example, other slightly unrelated 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! |
Las Vegas on a BudgetFind a BargainHotel DealsCheap EatsFree AttractionsEntertainment for Less |
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


