Need some clarification, VB vs .Net

davide128

Member
Joined
May 3, 2010
Messages
12
Programming Experience
Beginner
Ok..I understand that the The .NET class libraries are available to all CLI compliant languages. So If I'm programming in VB.net 8.0 lets say and vb 80 provides a method like UCASE and .net class library also has a toupper, which one is better to use.. I'm just a little confused as to when I should be looking to .NET class libraries versus using vb.net
 
Not all .Net class libraries are available in the CLI, the Microsoft.VisualBasic namespace isn't imported automatically in c#, j#, etc.. projects, so UCase() will not work by default in a c# project, but it will (unfortunately) in vb.net apps.

Everything you'd use in the Microsoft.VisualBasic namespace has a .net equivalent (which works the same in all the .Net languages) which is what you should be using anyways. Things like Trim(), Mid(), UCase(), LCase(), etc all shouldnt be used since they're all in the MS.VB namespace...
 
Some misunderstandings here. The VB Runtime functions is not for compatibility with VB6 code upgrade (those are in Microsoft.VisualBasic.Compatibility.dll), but helpful functions for any VB programmer, especially those coming from a VB6 background though. Most of them as suggested has a .Net framework equivalent, and in fact often simply call common .Net functions in their code. If you use them for example in a compiled class library you can reference this library in other .Net languages without problem. Other languages can also use these functions in code if they reference the Microsoft.VisualBasic.dll .Net library and using the VB namespace (Microsoft.VisualBasic). From a .Net and OOP perspective the VB runtime functions is kind of old school, but I don't think they will ever be removed from VB. Both Microsoft.VisualBasic and Microsoft.VisualBasic.Compatibility assemblies are marked CLSCompliant by the way, see also Cross-Language Interoperability.
 
Back
Top