Tag: RIGHT
VB.NET LEFT and RIGHT functions
by Tom Gee on Jan.06, 2010, under Programming, VB.NET
VBA and VB6 developers are used to the familiar LEFT and RIGHT string manipulation functions. However, VB.NET no longer has these functions built-in. As a result, when I create a new VB.NET application, I create the following two functions which I can then use to replicate the “old” LEFT and RIGHT functionality.
Public Function Left(ByVal Value As String, ByVal Length As Integer) As String
‘ Rereate a LEFT function for string manipulation
If Value.Length >= Length Then
Return Value.Substring(0, Length)
Else
Return Value
End If
End Function
Public Function Right(ByVal Value As String, ByVal Length As Integer) As String
‘ Recreate a RIGHT function for string manipulation
If Value.Length >= Length Then
Return Value.Substring(Value.Length – Length, Length)
Else
Return Value
End If
End Function