我在vb中有以下代码
Dim sStart As String, sEnd As String
sStart = ComboBoxYear.List(ComboBoxYear.ListIndex) & "-" & ComboBoxMonth.List(ComboBoxMonth.ListIndex) & "-1"
sEnd = Format(DateAdd("M", 1, CDate(sStart)) - 1, "yyyy-MMM-dd")
现在我已经在VB.NET中将其更改为
sStart = Me.ComboBoxYear.SelectedItem.ToString() & "-" & ComboBoxMonth.SelectedItem.ToString() & "-1"
sEnd = Format(DateAdd("M", 1, CDate(sStart)) & -1, "yyyy-MMM-dd")
但是 sEnd 将结果作为' yyyy-MMM-dd'只是,我在我的代码中做错了。
答案 0 :(得分:0)
尝试这样
sStart = Me.ComboBoxYear.SelectedItem.ToString() & "-" &
ComboBoxMonth.SelectedItem.ToString() & "-1"
sEnd =Format(CDate(DateAdd("M", 1, CDate(sStart)) & -1), "yyyy-MMM-dd")
在DateAdd("M", 1, CDate(sStart)) & -1