I have 2 textboxes, in first you type your word or sentence, on second textbox you type your character.
How do I count how many of this specific character is in first textbox?
I use Visual Studio 2010 vb.net
How do I count specific characters from sentence?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

ShankeyRank #972 · 2.1K reputationPosted Mar 7, 2011, 8:01 PM EST
private void countChar()
{
String str1 = txt1.Text;
char[] params1 = txt2.Text.ToCharArray();
//result.Text = "Count:" + txt1.Text.Replace(txt2.Text, "").Length;
foreach (char c in params1)
{
result.Text += "char " + c + " Count:" + Convert.ToString(txt1.Text.Split(c).Length - 1) + "
";
}
}
hope it works but if you want it in vb.net then i will post you soon but plz reply
Aki3 reputationPosted Mar 7, 2011, 11:59 PM EST
ShankeyRank #972 · 2.1K reputationPosted Mar 8, 2011, 12:28 AM EST
following in vb.net
Private Sub CharCount()
Dim str1 As [String] = txt1.Text
Dim params1 As Char() = txt2.Text.ToCharArray()
For Each c As Char In params1
result.Text += "char " & c & " Count:" & Convert.ToString(txt1.Text.Split(c).Length - 1) & "
"
Next
End Sub
It is what you need in vb.net