Solved

What is the purpose of the Microsoft.VisualBasic namespace?

Posted on 2007-04-04
6
207 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now