-
Left function
Hi,
In VB.NET, to use the Left function to extract characters from a string, I need to write:
Microsoft.VisualBasic.Strings.Left(strSomething, 5)
if just Left(strSomething, 5), it will points to Left of another Class.
This problem does not occur however for Mid() and Right() function.
Is there any way to eliminate this problem?
Thx~
-
Re: Left function
Those are old VB6 functions. Now we tend not to use them.
The Left you referred to is most likely the Left property of the Form you are working on, which will return an integer defining the horizontal position of the left edge of the form.
Lets say you want to grab the first 7 characters from "Hello World"...
MyString = "Hello World"
MyOtherString = Mystring.Substring(0,7)
'myotherstring now holds "Hello W"
-
Re: Left function
In my projects, I always remove the Microsoft.VisualBasic namespace from the imports list (see the project properties dialog) and use Option Strict On for all my code.
These measures ensure better coding practices.