Get Length of Strings in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This lesson describes the String.Length Property

The String type has a built-in Length property, which returns an integer that represents the number of characters in the string (its length).
Those characters include things like spaces as well as punctuation marks.

For example the string "Hello World!" is not only 10 characters long. Rather its length is 12 because of the empty space and the exclamation mark.

this example demonstrates the Length property:

    Dim MyString As String = String.Empty      
    MessageBox.Show(MyString.Length) ' = 0
    MyString = "Hello World!"     
    MessageBox.Show(MyString.Length) ' = 12         

Previous Lesson | Next Lesson

Share This

Home | About | Contact | Privacy Policy

Copyright 2018 - All Rights Reserved.