匹配出生日期和ID号的代码是什么 [英] what is the code for matching Date of Birth with an ID Number

查看:145
本文介绍了匹配出生日期和ID号的代码是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以提供代码来验证带有ID号的出生日期.我有2个texbox 1代表一个ID号,另外1个tex代表出生日期,用户1st在第一个文本框中输入ID号,他/她应该在另一个文本框上使用datepicker输入出生日期.因此,我想验证一下他/她的选择日期必须与ID Nubmer的前6个数字匹配:例如,如果不允许,则ID号9910231234567的出生日期应该为1999-10-23.请帮助.

can any one provide with the code to validate Date of Birth with an ID Number. i have 2 texbox 1 for an ID number and another 1 for Date fo Birth, user 1st enters ID number on the 1st textbox and he/she should enter date of birth using datepicker on another textbox. so i want to validate that when he/she pick date must match with the 1st 6 numbers of an id Nubmer: eg Id No 9910231234567 date of birth shoud be 1999-10-23 if any must not allow. pleas help.

推荐答案

获取ID的前六个字符的子字符串:
Take a Substring of the first six characters of the ID:
9910231234567 --->> 991023


现在在DateTimePicker.Value上使用ToString:


Now use ToString on the DateTimePicker.Value:

string s = dateTimePicker1.Value.ToString("yyMMdd");


并比较两个字符串.


And compare the two strings.




以下功能可能对您有用.

Hi,

below function may be useful for you.

bool compareID(DateTime selectedDate,double ID)
{
return selectedDate.ToString("yyMMdd") == ID.ToString().SubString(0,6) : true? false;
}



谢谢
-Amit.



Thanks
-Amit.


这篇关于匹配出生日期和ID号的代码是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆