Results 1 to 4 of 4

Thread: Getting the length of a string?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83

    Getting the length of a string?

    How to I get the length of a string? For example:

    VB.NET would be 5 characters long..

    I knew how to do this once upon a time.
    12/32/84 - I need some code to make me a sandwhich.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Just use the length method of the variable.
    VB Code:
    1. Dim a As String
    2.         a = "hello"
    3.         'To make the integer returned a string
    4.         MessageBox.Show(a.Length.ToString())
    5.  
    6.         Dim b As Integer
    7.         b = a.Length()

  3. #3
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Fort Collins, CO
    Posts
    366
    Fyi, "VB.NET" is 6 characters long. If you're variable is named say, MyString, then you can get the length with MyString.Length.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Thanks to both of you for the help!

    6... Yep My mistake.
    12/32/84 - I need some code to make me a sandwhich.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width