zoukankan      html  css  js  c++  java
  • 3/29日小作业,上一个任务的拓展,对三个输入框的检测。

    要求:对上一次的作业进行拓展,同时检测三个输入文本。

    对每个输入框的有效等价类与无效等价类与上次的相同。

    测试用例如下:

    编号 输入1 输入2 输入3 预期输出 实际输出
    test1 123456 abcdef abc123 √√√ 符合
    test2 !@#$%   1234567 ××× 符合
    test3 abc 测试 123!@# √×× 符合

    *注test2输入2为无输入。

    屏幕截图如下

    主要代码如下

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Text.RegularExpressions; 
    
    namespace WindowsFormsApplication3
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                String text1 = textBox1.Text;
                String text2 = textBox2.Text;
                String text3 = textBox3.Text;
    
                label4.Text = check_Text(text1, 0);
                label5.Text = check_Text(text2, 0);
                label6.Text = check_Text(text3, 0);
            }
    
            public String check_Text(String text, int mode)
            {
                return check_Text(text) == 0 ? "" : "×";
            }
    
            public int check_Text(String text)
            {
                Regex regex = new Regex(@"^[A-Za-z0-9]+$");
    
                int result = -1;
                if (text.Length > 6 || text.Length < 1)
                {
                    result = 1;
                }
                else if (!regex.IsMatch(text))
                {
                    result = 2;
                }
                else
                {
                    result = 0;
                }
                return result;
            }
        }
    }
    View Code

    全部文件如下(vs2013)

    https://files.cnblogs.com/files/limiting/3InputVersion.rar

  • 相关阅读:
    局域网内其他机器访问本机80网站失败记录
    百度经纬度获取
    Win10安装安卓ADB驱动
    SQL Server 查看数据库是否存在阻塞
    IP地址接口小结
    雄冠条码PV系统-2016-05-17-收获
    slf4j MDC使用
    Java NIO之通道
    Java NIO之缓冲区
    记一次ThreadPoolExecutor面试
  • 原文地址:https://www.cnblogs.com/limiting/p/4376428.html
Copyright © 2011-2022 走看看