【原创】对“学号”、“身份证”的数字分析(2)

来源:互联网 发布:2016网络大电影题材 编辑:程序博客网 时间:2024/05/16 11:05
摘要:
对身份证号码的分析同对学号的分析类似。

正文:
这里认为身份证号是18位的。

在页面上添加一个Label控件,一个TextBox控件,一个Button控件,一个Literal控件。Label控件的Text属性设为“身份证号:”,Literal控件将显示身份证号里的信息。关键还是在Button控件的Click()事件中。

Button控件的Click()事件:
            string strID = txtID.Text;

            
if (!txtID.Visible)
            
{
                txtID.Visible 
= true;
            }


            
try
            
{
                
string strYear = strID.Substring(6,4);        // 年    
                string strMonth = strID.Substring(10,2);    // 月
                string strDay = strID.Substring(12,2);        // 日

                Literal1.Text 
= "您的生日是:"+strYear+""+strMonth+""+strDay+"";
            }

            
catch
            
{
                Response.Write(
"程序有错误!");
            }

            
finally
            
{
            }

显示效果图:
o_image_06.png 
原创粉丝点击