0

此代码总是返回 '0' 我不知道为什么

Dim cur_month = DatePart(DateInterval.Month, Now).ToString()
Dim cur_date As String = "01/" + cur_month + "/" + (DatePart(DateInterval.Year, Now).ToString)
Dim sel_date As String = "01/" + (cmb_mnth.SelectedIndex + 1).ToString + "/" + txt_year.Text.ToString
Dim date_dif As String = DateDiff(DateInterval.Month, CDate(sel_date), CDate(cur_date))
MsgBox(date_dif)

cnb_mnth 是月份的组合框

txt_year 是输入年份的文本框

4

1 回答 1

1

我猜您计算机上的区域日期设置有前一个月(即 MM/dd/yyyy),因此它将 01 解释为 cur_date 和 sel_date 的月份。

于 2012-06-21T04:47:45.323 回答