Solved

What is the purpose of the Microsoft.VisualBasic namespace?

Posted on 2007-04-04
6
214 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 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 85

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Want to create a userform that looks like the image provided 10 63
Convert an ASPX page into PDF 7 32
Close tabpage of custom control 9 33
Close form "before" open 3 40
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…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

774 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