Dim dr As DataRow
dr=DataTables("Order").Find("planvsactual = 'Actual' and so_no ='" & e.node.Name & "'")
If dr IsNot Nothing Then
For Each c As WinForm.Control In e.Form.Controls
If Typeof c Is WinForm.CheckBox Then '判断控件是否是文本框
Dim t As WinForm.CheckBox = c '使用特定类型的变量引用控件
For Each Cl As DataCol In DataTables("Order").DataCols
If cl.name = t.name And dr(cl.name) <> #1/1/1 0:00:00# Then
t.Checked=True
MessageBox.Show(cl.name & t.name & dr(cl.name))
End If
Next
End If
Next
End If
上面这个代码会出错。显示:从字符串“1232ff”到类型“Date”的转换无效。
下面这个代码就运行正常
Dim dr As DataRow
dr=DataTables("Order").Find("planvsactual = 'Actual' and so_no ='" & e.node.Name & "'")
If dr IsNot Nothing Then
For Each c As WinForm.Control In e.Form.Controls
If Typeof c Is WinForm.CheckBox Then '判断控件是否是文本框
Dim t As WinForm.CheckBox = c '使用特定类型的变量引用控件
For Each Cl As DataCol In DataTables("Order").DataCols
If cl.name = t.name Andalso dr(cl.name) <> #1/1/1 0:00:00# Then
t.Checked=True
MessageBox.Show(cl.name & t.name & dr(cl.name))
End If
Next
End If
Next
End If
有人知道为什么么?是“=”运行的先后顺序么?