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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ShankeyPosted Mar 8, 2011, 5:28 AM
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
AkiPosted Mar 8, 2011, 4:59 AM
ShankeyPosted Mar 8, 2011, 1:01 AM
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