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

博客介绍了在页面上通过添加Label、TextBox、Button和Literal控件,利用Button控件的Click()事件对18位身份证号进行分析,提取其中的生日信息并显示在Literal控件上,若程序出错则给出错误提示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

摘要:
对身份证号码的分析同对学号的分析类似。

正文:
这里认为身份证号是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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值