Visual Basic - Import The Visual Basic Namespace To Access Some Legacy Features (VB .NET)


In a recent tip, we reported that you can no longer access the Left and Right string functions in Visual Basic .NET. As many of our subscribers pointed out, that isn't entirely true. While these functions aren't a part of .NET's String class, you can still access them by importing the Visual Basic namespace.


To do so, place:


Imports Microsoft.VisualBasic, at the top of your class and then you can use code similar to the following to use the legacy functions:


  • Dim myString As String = "Visual Basic"
  • MsgBox(Strings.Left(myString, 6))
  • MsgBox(Strings.Right(myString, 6))

Go back