Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7723047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:20:40+00:00 2026-06-01T04:20:40+00:00

Possible Duplicate: Count specific character occurances in string I have a delimeter in string

  • 0

Possible Duplicate:
Count specific character occurances in string

I have a delimeter in string that i have to validate. How can I count occurrences of that char. For now i have a next function.

Private Shared Function CountChars(ByVal value As String) As Integer
    Dim count = 0
    For Each c As Char In value
        If c = "$"c Then
            count += 1
        End If
    Next
    Return count
End Function

Any alternative solution that looks better?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:20:41+00:00Added an answer on June 1, 2026 at 4:20 am

    Or you could use LINQ..

    Private Function CountChars(ByVal value As String) As Integer
    
        Return value.ToCharArray().Count(Function(c) c = "$"c)
    
    End Function
    

    As Meta-Knight has pointed out it can be shortened to:

    value.Count(Function(c) c = "$"c)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
Possible Duplicate: How can I count the numbers of rows that a mysql query
Possible Duplicate: How do I count the number of occurrences of a char in
Possible Duplicate: How would you count occurences of a string within a string (C#)?
Possible Duplicate: NSNumber retain count issue Hello, I have the following code: NSNumber *number
Possible Duplicate: How to count the number of lines in an Objective-C string (NSString)?
Possible Duplicate: How would you count occurences of a string within a string (C#)?
Possible Duplicate: Case insensitive string comparison in C++ C++ count and map How to
Possible Duplicate: check number of a given character occurence in a String I'm trying
Possible Duplicate: Hibernate HQL: Get count of results without actually returning them I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.