Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Check if Object Variable has been Set to Nothing

Is there any way to check if an object variable was set to Nothing?
0
HangTenDesign
Asked:
HangTenDesign
  • 3
1 Solution
 
Ryan ChongCommented:
try:

<%

if obj is nothing then
  response.write "obj is nothing"
else
  response.write "obj is not nothing"
end if

%>
0
 
hongjunCommented:
Simple example

<%
Dim conn

Set conn = CreateObject("ADODB.Connection")

If IsObject(conn) Then
    Response.Write "Is object<br>"
    If conn Is Nothing Then
        Response.Write "Nothing<br>"
    Else
        Response.Write "Not Nothing<br>"
    End If
Else
    Response.Write "Is Not object<br>"
End If

Set conn = Nothing

If IsObject(conn) Then
    Response.Write "Is object<br>"
    If conn Is Nothing Then
        Response.Write "Nothing<br>"
    Else
        Response.Write "Not Nothing<br>"
    End If
Else
    Response.Write "Is Not object<br>"
End If
%>


hongjun
0
 
HangTenDesignAuthor Commented:
I found a really good snippet at FourGuys... http://www.4guysfromrolla.com/webtech/tips/t021000-1.shtml
0
 
hongjunCommented:
oops!!!
a bit duplicated posting.
0
 
hongjunCommented:
ryancys,

    your deserved points here http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21360178.html

hongjun
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now