zoukankan      html  css  js  c++  java
  • textBox里仅限输入IP格式 转

    bool blnTest = false;
    bool _Result = true;

    Regex regex = new Regex("^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$");
    blnTest = regex.IsMatch(textEdit1.Text);
    if (blnTest == true)
    {
    string[] strTemp = this.textEdit1.Text.Split(new char[] { '.' }); // textBox1.Text.Split(new char[] { '.' });
    for (int i = 0; i < strTemp.Length; i++)
    {
    if (Convert.ToInt32(strTemp[i]) > 255)
    { //大于255则提示,不符合IP格式
    MessageBox.Show("不符合IP格式");
    _Result = false;
    }
    }
    }
    else
    {
    //输入非数字则提示,不符合IP格式
    MessageBox.Show("不符合IP格式");
    _Result = false;
    }
  • 相关阅读:
    寒假学习10
    寒假学习9
    寒假学习8
    寒假学期7
    寒假学习6
    寒假学习5
    寒假学习4
    Notification通知栏的使用
    Service的使用
    BroadcastReceive的使用
  • 原文地址:https://www.cnblogs.com/liye/p/1568539.html
Copyright © 2011-2022 走看看