在我的DataTable中有两列:
With colA
.DataType = System.Type.GetType("System.String")
.ColumnName = "colA"
End With
With colB
.DataType = System.Type.GetType("System.String")
.ColumnName = "colB"
End With我想将其添加到.expression到colB中,这将测试来自colA的字符串值,如果True放置字符串值,如果为False,则测试另一个字符串值。
有件事是这样的:
colB.Expression = IIF(colA="toto", "cool", "not cool")但我在语法上有困难。每次对表达式的评估都是错误的。
更新:--我尝试了这个和这个工作:
colB.Expression = "IIF([colA] = 'stringA', 'stringB', 'stringC')"但是现在,如果我想测试一个空值,语法是什么?
发布于 2018-04-11 13:30:40
要测试是否为空:
colB.Expression = "IIF([colA] = '', 'stringB', 'stringC')"要测试null,请执行以下操作:
colB.Expression = "IIF([colA] IS NULL, 'stringB', 'stringC')"若要测试空或空,请执行以下操作:
colB.Expression = "IIF([colA] = '' or [colA] IS NULL, 'stringB', 'stringC')"https://stackoverflow.com/questions/49769584
复制相似问题