Results 1 to 3 of 3

Thread: Character count from string

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    111

    Character count from string

    Hi all,

    I would like to know how i can count the character from a string.

    dim mystring as string = "myfilename_employee--2010-11-23-45-00--empid200"

    i need to see if this string have "--" two if it is less or more than two i need to alert to the user.

    Thank You

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Character count from string

    You can use a regular expression to check how many times a string appears.
    Code:
            Dim s As String
            s = "myfilename_employee--2010-11-23-45-00--empid200"
            If System.Text.RegularExpressions.Regex.Matches(s, "--").Count <> 2 Then
                MessageBox.Show("You must have two sets of two dashes in the file name")
            End If

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    111

    Re: Character count from string

    great!
    thank you

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