错误:年,月和日参数描述不可表示的DateTime

时间:2017-02-21 02:21:12

标签: vb.net

我收到错误YearMonthDay参数描述了无法表示的DateTime,如下面的代码

 FristDate = New Date(Year(frm.dtpInMonth.Value), Month(frm.dtpInMonth.Value), "-1")

enter image description here

1 个答案:

答案 0 :(得分:-2)

虽然您的问题不清楚且信息量较少,但我认为您应该尝试以下代码:

Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click Dim FirstDate As Date Dim cDay As Integer = dtpInDay.Text Dim cMonth As Integer = dtpInMonth.Text Dim cYear As Integer = dtpInYear.Text FirstDate = New DateTime(cYear, cMonth, cDay) txtTest.Text = FirstDate.ToString End Sub

  

请添加表格的截图

使用我的代码的表单截图:

1