?
Solved

What is the purpose of the Microsoft.VisualBasic namespace?

Posted on 2007-04-04
6
Medium Priority
?
234 Views
Last Modified: 2010-04-23
Is the Microsoft.VisualBasic namespace in VB.NET 2003 and VB 2005 just for backwards compatibility with VB6? Is it something I should be trying to avoid and be using equivalents in .NET?
0
Comment
Question by:SETP
6 Comments
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 600 total points
ID: 18849507
Depends on if your projects still have some vb6 dependencies.
It's more for a transition from vb6 to .net.
I wouldn't say you should be trying to 'avoid' it, but you can move away from it by using .net terminology in your code instead...
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 600 total points
ID: 18849667
as an example, if you are coming from a VB6 background, then you are quite familiar with MsgBox.

MsgBox is supported in .NET, but requires including a reference to the Microsoft.VisualBasic namespace.  

The .NET equivalent is MessageBox.Show() - which does not require the reference to the Microsoft.VisualBasic namespace.

It is strongly advised to use MessageBox.Show() in all VB.NET applications.

AW
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 800 total points
ID: 18851695
Not everything in Microsoft.VisualBasic is for backwards compatability!...

Most of this stuff is for legacy code:
http://msdn2.microsoft.com/en-us/library/c157t28f(vs.80).aspx

BUT you have entirely NEW classes/functionality being added to that namespace as well.  Some of the new namespaces were placed there to support the new "My.XXX" functions in VB.Net 2005.

The new Application Model was placed in there:
http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.aspx
You can do things easily with the new application model that before required complex interprocess code.  It even has new events that allow you to do things before the first form ever fires up.

The new Devices support is there:
http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.devices(vs.80).aspx

The FileIO namespace has new utilities (like TextFieldParser) that are pretty nice:
http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.fileio(VS.80).aspx
It also has the backbone of the My.Computer.FileSystem.XXX namespace which gives you alot of "one liners" that allow you to work with files, etc...

Logging:
http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.logging(VS.80).aspx

MyServices:
http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.myservices(VS.80).aspx

Some of these things you would access thru the "My.XXX" syntax but others can be used directly.

So don't "avoid the namespace" but DO avoid using the legacy functions and use the newer .Net syntax equivalents.  This way your code will be more consistent with other .Net applications and make it easier to read.  Many of the legacy functions are still "one based" instead of "zero based" which can cause confusion and errors in code if you mix the legacy functions with newer .Net functions.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SETP
ID: 18857654
Thanks guys
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 18858930
glad to be of assistance.

AW
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18860574
:)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question