Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Manipulation 1

Status
Not open for further replies.

sp76

Programmer
Jul 1, 2003
59
AU
How can i find how many times a character appears in a string.

for eg.

i want to find how many times "a" occures in "Visual Basic"
 
Dim i As Integer = myString.Split("a"c).Length()


Sweep
...if it works dont mess with it
 

this is how you can do it .NET way

Dim myRegex As New Regex("a")
Dim myString As String = "Visual Basic"
Dim mc As MatchCollection = myRegex.Matches(myString)
MessageBox.Show(mc.Count)

Email: pankajmsm@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top