|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
how many letters? help plz
the text "Hello dude" consists of 6 diffent letters... i got a text in written into a textbox , and i want to check how many diffrent letters there is.. how ? i saw someone use [a-z] thing, but i didnt quite get it... any sugestions ?
|
|
#2
|
|||
|
|||
|
I'm not the best person to ask but no-oneelse seems to be answering your pleas.
I can offer two solutions neither of which are perfect. The first is a solution that will only work if you know what characters are in the string, and that would be to just split the string by all of those characters: string s = "whatever"; string[] spl = s.Split('w'); int amountOfThisCharacter = spl.length; and so on with all your letters. 2nd is to write a time consuming switch: foreach(char c in string s) { switch(c) { case 'a': aCtr++; break; case 'b': bCtr++; break; } } and so on...... Neither of these solutions are perfect, but they will work. jax |
|
#3
|
|||
|
|||
I am not sure what language you are using, but try this in VB.NET: Sub BlahBlah() Dim i, pintCountUniqueLetters as integer 'just to keep count Dim YourString as String 'At some point after you have set a value for YourString YourString = YourString.ToUpper For i = 65 to 90 If YourString.IndexOf(Chr(i) <> -1 Then YourString.Replace(Chr(i),"") pintCountUniqueLetters +=1 End If Next End Sub This should work |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > how many letters? help plz |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|