Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何检查datagridview单元格是否带有数字_Vb.net_Visual Studio 2010_Datagridview_Datagrid - Fatal编程技术网

Vb.net 如何检查datagridview单元格是否带有数字

Vb.net 如何检查datagridview单元格是否带有数字,vb.net,visual-studio-2010,datagridview,datagrid,Vb.net,Visual Studio 2010,Datagridview,Datagrid,如何检查Datagridview是否有值。。。?例如: If DatagridviewRows(i).Cells(2).Value have a value and DatagridviewRows(i).Cells(3).Value Then DatagridviewRows(i).Cells(2).Value = "autosum" 我不想使用If not Datagridview is nothing或string.empty。正如Zohar Pele

如何检查Datagridview是否有值。。。?例如:

If DatagridviewRows(i).Cells(2).Value have a value and  
      DatagridviewRows(i).Cells(3).Value Then 
         DatagridviewRows(i).Cells(2).Value = "autosum"

我不想使用If not Datagridview is nothing或string.empty。

正如Zohar Peled在评论中所说,您必须使用nothing关键字的一些变体。这是因为单元格存储了一个对象,它是引用类型,没有什么是检查引用类型的正确方法

您不必使用以下格式:

If Not value Is Nothing Then
如果你不喜欢这种格式。您可以改为使用:

If value IsNot Nothing Then
从可读性的角度来看,它更符合VB的英语句子式符号


以上两种方法都可以做到。

因为datagridview单元格值是一个对象,所以即使您不喜欢,也必须使用nothing关键字。