Friday, November 19, 2010

What vb.net command do you use to count characters in a string?

I am using vb.net express 2007 and cannot figure out how to get my program to count certain characters in a string, then display the findings!What vb.net command do you use to count characters in a string?
value = someString.Length



That's how you get the size of a string. If you want to count certain characters, you'll have to loop over the string char by char using a FOR loop. Then use someString.Chars(i).What vb.net command do you use to count characters in a string?
dim s as string

s=';abc';

dim count as int

i=s.lenght
Use the string.length property to get the length of a string.



Dim s As String

Dim c As Integer

s = ';Hello World';

c = s.Length

Console.WriteLine(c)

Console.ReadLine()

No comments:

Post a Comment