我如何...解决错误对象引用未设置为对象的实例? [英] How do I...solve error Object reference not set to an instance of an object?

查看:70
本文介绍了我如何...解决错误对象引用未设置为对象的实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意我是vb.net的新用户



我收到此错误对象引用未设置为对象的实例,并且这是我的代码的和平



  .timerCOUNTS。< span class =code-keyword>停止()
Dim StartKickout As 布尔 = CBool​​ (ta_KICKOUT.GetDataKickout.Rows( 0 )。项目( 0 ))< ---这里错误
如果 StartKickout 然后
TimerKickout.Start()
如果 frmEnvironment.ChildFormPRD.Visible 然后
MsgBox( 应用程序将关闭在10秒,MsgBoxStyle.OkOnly)
ElseIf frmEnvironment.childformQA.Visible 然后
MsgBox( 应用程序将在10秒内关闭,MsgBoxStyle.OkOnly)
结束 如果
.timerCOUNTS.Start()
退出 Sub
结束 如果





谢谢advance

解决方案

C#代码在这里:

  if (ta_KICKOUT.GetDataKickout!=  null 
{
if (ta_KICKOUT.GetDataKicko ut.Rows( 0 )!= null
{
if (ta_KICKOUT.GetDataKickout.Rows( 0 )。Item( 0 )!= null
{
// 请在使用之前检查对象是否为空
// 然后在这里进行编码
}
}
}



Bellow是等效的VB代码。

 如果 ta_KICKOUT.GetDataKickout  IsNot   Nothing  然后 
如果 ta_KICKOUT.GetDataKickout.Rows( 0 IsNot 没什么 然后
' 请在使用之前检查对象是否为
' 然后在此处进行编码
如果 ta_KICKOUT.GetDataKickout.Rows( 0 )。项目( 0 IsNot 没什么 然后
< span class =code-keyword>结束 如果
结束 如果
结束 如果


Hi,please note i am new in vb.net

I have been getting this error "Object reference not set to an instance of an object", and here is a peace of my code

Me.timerCOUNTS.Stop()
 Dim StartKickout As Boolean = CBool(ta_KICKOUT.GetDataKickout.Rows(0).Item(0))<---error here
        If StartKickout Then
            TimerKickout.Start()
            If frmEnvironment.ChildFormPRD.Visible Then
                MsgBox("The application will shutdown in 10 seconds", MsgBoxStyle.OkOnly)
            ElseIf frmEnvironment.childformQA.Visible Then
                MsgBox("The application will shutdown in 10 seconds", MsgBoxStyle.OkOnly)
            End If
            Me.timerCOUNTS.Start()
            Exit Sub
        End If



Thanks in advance

解决方案

C# code goes here:

if(ta_KICKOUT.GetDataKickout !=null)
{
if(ta_KICKOUT.GetDataKickout.Rows(0)!=null)
{
if(ta_KICKOUT.GetDataKickout.Rows(0).Item(0)!=null)
{
//Please check the object for Null before use that
//Then do your coding here
}
}
}


Bellow is the equivalent VB code.

If ta_KICKOUT.GetDataKickout IsNot Nothing Then
	If ta_KICKOUT.GetDataKickout.Rows(0) IsNot Nothing Then
				'Please check the object for Null before use that
				'Then do your coding here
		If ta_KICKOUT.GetDataKickout.Rows(0).Item(0) IsNot Nothing Then
		End If
	End If
End If


这篇关于我如何...解决错误对象引用未设置为对象的实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆