C#中不能用正则表达式,VB是可以的。

解决方案 »

  1.   

    KillCat你的Regex.Match是什么意思,看不懂。Vs.Net中help连你写的关键字都查不到,是否是简写,拜托写清楚些好吗?不胜感激!!!
      

  2.   

    private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    switch(e.KeyChar)
    {
    case '$':
    {
    if(((TextBox)sender).Text.Length > 0)
    {
    e.Handled = true;
    } break;
    }
    case '.':
    {
    if(((TextBox)sender).Text.IndexOf(".") > 0)
    {
    e.Handled = true;
    } break;
    }
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
    case '0':
    {
    break;
    }
    default:
    {
    e.Handled = true;
    break;
    }
    }//switch
    }
      

  3.   

    switch (Style)
        {
    case uTextBox_style.Numeric:
    string strSymbol="-+.";
    if ((Char.IsDigit(e.KeyChar)) | (Char.IsControl(e.KeyChar)) | (strSymbol.IndexOf(e.KeyChar.ToString())!=-1))
    {
    }
    else
    {
    e.Handled=true;
    }
    break;
    }