Tipos de Métodos de Manipulação de Cadeia de Caracteres em Visual Basic
There are several different ways to analyze and manipulate your strings. Some of the methods are a part of the Visual Basic language, and others are inherent in the String class.
Visual Basic Language and the .NET Framework
Visual Basic methods are used as inherent functions of the language. They may be used without qualification in your code. The following example shows typical use of a Visual Basic string-manipulation command:
Dim aString As String = "SomeString"
Dim bString As String
' Assign "meS" to bString.
bString = Mid(aString, 3, 3)
In this example, the Mid function performs a direct operation on aString and assigns the value to bString.
Para obter uma lista dos métodos de manipulação de seqüência de caracteres Visual Basic, consulte Resumo de manipulação de sequência de caracteres (Visual Basic).
Shared Methods and Instance Methods
You can also manipulate strings with the methods of the String class. Há dois tipos de métodos em String: compartilhado métodos e instância métodos.
Shared Methods
A shared method is a method that stems from the String class itself and does not require an instance of that class to work. These methods can be qualified with the name of the class (String) rather than with an instance of the String class. For example:
Dim aString As String = String.Copy("A literal string")
In the preceding example, the String.Copy method is a static method, which acts upon an expression it is given and assigns the resulting value to bString.
Instance Methods
Instance methods, by contrast, stem from a particular instance of String and must be qualified with the instance name. For example:
Dim aString As String = "A String"
Dim bString As String
' Assign "String" to bString.
bString = aString.Substring(2, 6)
In this example, the String.Substring method is a method of the instance of String (that is, aString). It performs an operation on aString and assigns that value to bString.
Para obter mais informações, consulte a documentação para o deStringclasse.