Objective1 TextBox txtExtractNo
2 TextBox txtInput
3 TextBox txtresult
1 Button -- List
2 Button -- Result
ex: txtExtractNo -- 2
txtInput -- 20
txtresult -- 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
List -- Click List button you can see the txtresult Data.
Result -- Click Result button .You can see the Messagebox with counting of numbers(How many 2's in the txtresult box)
// write code hereMember Declaration
public static int result;
int chk;
Function:
private int CompareText(string fValue, string svalue)
{
string formHeading = fValue;
string userSearch = svalue;
string constring = string.Empty;
string comstring = string.Empty;
string[] formHeadingWords;
string[] userSearchWords;
formHeadingWords = System.Text.RegularExpressions.Regex.Split(formHeading, @"\W");
userSearchWords = System.Text.RegularExpressions.Regex.Split(userSearch, @"\W");
int cntFarray = formHeadingWords.Length;
int cntSarray = userSearchWords.Length;
if (cntSarray > cntFarray)
{
foreach (string _str in userSearchWords)
{
int strlength = _str.Length;
if (strlength == 1)
{
if (formHeading.Contains(_str))
{
chk = 1;
}
}
else if (strlength > 1 )
{
thechars = _str.ToCharArray();
for (int idx = 0; idx < thechars.Length; idx++)
{
if (formHeading.Contains(thechars[idx]))
{
chk = chk + 1;
}
}
}
}
}
result = chk;
return result;
}
private void button1_Click(object sender, EventArgs e)
{
for (int idx = 1; idx <= Convert.ToInt32(textBox1.Text); idx++)
{
if (str == null)
{
str = Convert.ToString(idx);
}
else
{
str = str + "," + Convert.ToString(idx);
}
}
textBox3.Text = str;
}
private void button2_Click(object sender, EventArgs e)
{
int chkvalue = Convert.ToInt32(textBox2.Text);
int str = CompareText(textBox2.Text, textBox3.Text);
MessageBox.Show(Convert.ToString(str));
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
str = null;
}Output is : 3..
Conclusion So you can get how many numbers in the list.Thanks for reading this articles.any feedback :please contact this ID:irnaraayanan@yahoo.com