N
Nobody
If you want to use Left/Right in VB.Net forms without having to prepend them
with "Microsoft.VisualBasic", or an alias like "VB.", you can use this
method. It involves "hiding" or shadowing the Left and Right properties of
the Form by using Shadows keyword, and provide your own functions. You can
still access the Left/Right properties of your form by prefixing them with
MyBase keyword. Example:
Public Class Form1
Private Shadows Function Left(ByRef s As String, ByVal n As Integer) As
String
Return Microsoft.VisualBasic.Left(s, n)
End Function
Private Shadows Function Right(ByRef s As String, ByVal n As Integer) As
String
Return Microsoft.VisualBasic.Right(s, n)
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim s As String
s = "Hello world!"
Console.WriteLine(Left(s, 5))
Console.WriteLine(Right(s, 5))
Console.WriteLine(Mid(s, 5, 1))
Console.WriteLine(MyBase.Left)
Console.WriteLine(MyBase.Right)
End Sub
End Class
Output:
Hello
orld!
o
154
454
with "Microsoft.VisualBasic", or an alias like "VB.", you can use this
method. It involves "hiding" or shadowing the Left and Right properties of
the Form by using Shadows keyword, and provide your own functions. You can
still access the Left/Right properties of your form by prefixing them with
MyBase keyword. Example:
Public Class Form1
Private Shadows Function Left(ByRef s As String, ByVal n As Integer) As
String
Return Microsoft.VisualBasic.Left(s, n)
End Function
Private Shadows Function Right(ByRef s As String, ByVal n As Integer) As
String
Return Microsoft.VisualBasic.Right(s, n)
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim s As String
s = "Hello world!"
Console.WriteLine(Left(s, 5))
Console.WriteLine(Right(s, 5))
Console.WriteLine(Mid(s, 5, 1))
Console.WriteLine(MyBase.Left)
Console.WriteLine(MyBase.Right)
End Sub
End Class
Output:
Hello
orld!
o
154
454