How to: Access Characters in Strings in Visual Basic
This example demonstrates how to use the Chars property to access the character at the specified location in a string.
Sometimes it is useful to have data about the characters in your string and the positions of those characters within your string. You can think of a string as an array of characters (
Char instances); you can retrieve a particular character by referencing the index of that character through the Chars property.
Dim myString As String = "ABCDE" Dim myChar As Char ' Assign "D" to myChar. myChar = myString.Chars(3)
index parameter of the Chars property is zero-based.
The Chars property returns the character at the specified position. However, some Unicode characters can be represented by more than one character. For more information on how to work with Unicode characters, see How to: Convert a String to an Array of Characters.