日期:2014-05-17 浏览次数:20890 次
int count = Regex.Matches(textBox1.Text, "[A-Z]").Count;
MessageBox.Show("有" + count + "个大写字母");
private int i = 0;
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
//大写字母A-Z的ASC码范围是65-90;
if ((int)e.KeyChar > 65 & (int)e.KeyChar < 90
------解决方案--------------------
(int)e.KeyChar == 8)
{
i++;
}
MessageBox.Show(i.ToString());
}