Solved

What is the purpose of the Microsoft.VisualBasic namespace?

Posted on 2007-04-04
6
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 150 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 150 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 200 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
Technology Partners: 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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