作者moneylove (money)
看板C_Sharp
標題[問題] 有關日期的問題
時間Tue Oct 12 21:23:23 2010
int count2 = 0;
for (int i = 0; i <= txt1.Length - 1; i++)
{
string d1 = txt1[i].Text.Trim();
string d2 = TextBox4.Text.Trim();
if (txt1[i].Text.Trim() == "")
{
continue;
}
else if (DateTime.ParseExact(d1, "MM/dd/yyyy", null) >
DateTime.ParseExact(d2, "MM/dd/yyyy", null))
{
System.Windows.Forms.MessageBox.Show("第"+(i+1)+"行的
"+txt1[i].Text.Trim()+"比上市日期還要大");
count2++;
break;
}
}
如果我的textBox輸入的日期為12/09/2010(MM/DD/YYYY)
他抓到的字串會變成12/9/2010那就不符合格式
請問各位大大這有辦法解決嗎????
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.175.223
※ 編輯: moneylove 來自: 140.123.175.223 (10/12 21:23)
→ ssccg:用Parse不要用ParseExact ? 10/12 21:26
→ moneylove:可以唷~~ 謝謝~ 10/12 21:53
→ moneylove:可以在問一下,就是在MANAGEMENT STUDIO裡面加IDENETITY 10/12 21:55