Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing for NULL objects
Message
De
21/03/2007 08:07:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
21/03/2007 06:04:28
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01206415
Message ID:
01206445
Vues:
14
>How can I test if an object is NULL?
>
>I am trying to build the hierarchy of an object ;
>
>
>Function GetHierarchy(ByVal toObject As Object)
>Dim lcHierarchy As String
>Dim loObject As Object
>loObject = toObject
>lcHierarchy = loObject.Name
>
>Do
>  If VarType(loObject.Parent) = Nothing Then
>    Exit Do
>  Else
>    loObject = loObject.Parent
>    lcHierarchy = loObject.Name & "." & lcHierarchy
>  End If
>Loop
>Return lcHierarchy
>End Function
>
>
>The problem is that VarType(loObject.Parent) returns Object{9} even if .parent is a null value and loObject.Parent = Nothing generates an error if loObject.parent is not Null
>
>In VFP I would have used ISNULL() but I know there is no direct equivelant in VB.NET so how can I check for loObject.Parent being null?
>
>Regards
>
>
>
>Gary Williams.

Gary,
It should be:

if loObject.Parent = Nothing

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform