从“TimeSpan”类型到“日期”类型的转换无效。 [英] Conversion from type 'TimeSpan' to type 'Date' is not valid.
问题描述
这是我编辑功能的早期阶段。请帮助我,我应该在这种错误中写出什么转换代码?
错误消息(从'TimeSpan'类型转换为类型'日期'无效。)
> datetimepicker3和4设置为选择时间
> me.datagridview1.row(i).cells(4).value()是选定的行,单元格值,是时间的数据类型(7)
>我的任务是双击datagridview.row并强制该值显示在指定的文本框和datetimepickers上。
>但是错误发生在11& 12
这是我的错误代码:
This is the earlier stage of my edit feature. Help me please, what convert codes should i write in this kind of error?
error msg (Conversion from type 'TimeSpan' to type 'Date' is not valid.)
>datetimepicker3 and 4 are set to choose times
>me.datagridview1.row(i).cells(4).value() is the selected row,cell value and is in the datatype of time(7)
> my mission is to double click on the datagridview.row and force the value to show on specified textboxes and datetimepickers.
>but errors occurred codes lines in 11 & 12
Here's my codes with errors:
Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Dim i As Integer
i = DataGridView1.SelectedCells(0).RowIndex
Me.TextBox6.Text = Me.DataGridView1.Rows(i).Cells(6).Value.ToString()
Me.TextBox8.Text = Me.DataGridView1.Rows(i).Cells(8).Value.ToString()
Me.RichTextBox1.Text = Me.DataGridView1.Rows(i).Cells(7).Value.ToString()
Me.TextBox9.Text = Me.DataGridView1.Rows(i).Cells(9).Value.ToString()
Me.DateTimePicker1.Value = Me.DataGridView1.Rows(i).Cells(2).Value()
Me.DateTimePicker2.Value = Me.DataGridView1.Rows(i).Cells(3).Value()
'Me.DateTimePicker3.Value = Me.DataGridView1.Rows(i).Cells(4).Value()
'Me.DateTimePicker4.Value = Me.DataGridView1.Rows(i).Cells(5).Value()
If Me.DataGridView1.Rows(i).Cells(10).Value.ToString() = RadioButton1.Text Then
Me.RadioButton1.Checked = True
ElseIf Me.DataGridView1.Rows(i).Cells(10).Value.ToString() = RadioButton2.Text Then
Me.RadioButton2.Checked = True
ElseIf Me.DataGridView1.Rows(i).Cells(10).Value.ToString() = RadioButton3.Text Then
Me.RadioButton3.Checked = True
End If
End Sub
推荐答案
if Me.DataGridView1.Rows(i).Cells(5).Value is dbnull then
msgbox(".....")
else
Me.DateTimePicker4.text = Me.DataGridView1.Rows(i).Cells(5).Value()
end if
这篇关于从“TimeSpan”类型到“日期”类型的转换无效。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!