C# TextBox電子郵件驗證

private void TextBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (TextBox1.Text==string.Empty)
                errorProvider1.SetError(TextBox1, "");
            else
                if (!(Regex.IsMatch(TextBox1.Text,
                              @"^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$")))
                {
                    errorProvider1.SetError(TextBox1, "電子郵件地址務必採用 abc@cccc.ccc.cc 的格式。");
                    e.Cancel = true;
                }
                else
                {
                    errorProvider1.SetError(TextBox1, "");
                    e.Cancel = false;
                }
        }


janema66 發表在 痞客邦 留言(0) 人氣()

C#  TextBox只能夠輸入數字及小數點

private void InitializeComponent()

 this.TextBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TextBoxF_32B_2_KeyPress);


 private void TextBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if (e.KeyChar.CompareTo('\b') == 0)
                e.Handled = false;
            else if ((e.KeyChar.CompareTo('0') < 0 || e.KeyChar.CompareTo('9') > 0) && !(e.KeyChar.CompareTo('.') == 0)) //比較輸入值的範圍是否超出數字
                e.Handled = true;// Handled 為是否鎖住輸入

        }


janema66 發表在 痞客邦 留言(0) 人氣()

Crystal Reports

SELECT  field01, field02  From Table

報表顯示
欄位一          欄位二           比例
=======     ========    ==========
field01        field02           field01 % field02

若遇到field01 及 field02為null值時
此欄位都不會顯示值,user端希望能顯示 "-" 

修改成
SELECT ISNULL(field01, 0), ISNULL(field02, 0) FROM Table
則會造成,下列錯誤訊息
Division by zero

再修改 比例 欄位公式

if {field02}=0 then
   "-"
else
   CSTR({field01} % {field02})+'%'



janema66 發表在 痞客邦 留言(0) 人氣()