Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try
parent = vbNullString "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You might want to use something other than parent - might be reserved.
anyway try: set parent=Nothing -- Gary''s Student - gsnu200726 "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Gary''s Student" schreef in bericht ... You might want to use something other than parent - might be reserved. anyway try: set parent=Nothing -- Gary''s Student - gsnu200726 And 'Node' is reserved as well. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
try parent = "" regards FSt1 "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
First, take a look at Null in VBA Help.
To dissociate object variables from their objects, you set them to Nothing: Set parent = Nothing For most simple cases, that's not really necessary since the object will be destroyed when the object variable goes out of scope (i.e., when the Sub exits). In article , vivmaha wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'll try all of these work arounds. I'll only be able to test if they work
when my application is 'semi-complete'. Why are all of these work arounds? Is there no such 'null' as there is in other languages? "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Set someObject = Nothing is a perfectly normal thing to do *in VBA*: it's not a "workaround". I suspect that some of the other suggestions you got were from mis-reading your original question. Tim "vivmaha" wrote in message ... I'll try all of these work arounds. I'll only be able to test if they work when my application is 'semi-complete'. Why are all of these work arounds? Is there no such 'null' as there is in other languages? "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
They're not really workarounds - just not positive what you are trying to
accomplish. It looks to me like the suggestions using "", vbnullstring, etc were prompted by you not using a set statement in the example provided (which is required for objects). It looks like you could be trying to assign null to a default property of the parent object or you could be trying to destroy the parent object itself (ie-set it to nothing). "vivmaha" wrote: I'll try all of these work arounds. I'll only be able to test if they work when my application is 'semi-complete'. Why are all of these work arounds? Is there no such 'null' as there is in other languages? "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It seems that your idea that "work arounds" are required stems from your
misunderstanding the VBA/VB language and what Null means. To me, outside of a database environment, it does not have a real meaning in VBA, where you have Nothing for objects and Empty for variants (although you can use Null with a Variant also) & vbNullString for strings. Private Sub CommandButton1_Click() Dim Nullable As Variant Nullable = "some string" Nullable = Null Debug.Print IsNull(Nullable) Nullable = "some string" Nullable = Empty Debug.Print IsNull(Nullable) Dim NullStr As String NullStr = "Null String" NullStr = vbNullString Debug.Print IsNull(NullStr) End Sub NickHK "vivmaha" wrote in message ... I'll try all of these work arounds. I'll only be able to test if they work when my application is 'semi-complete'. Why are all of these work arounds? Is there no such 'null' as there is in other languages? "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Set parent = Nothing
Tim "vivmaha" wrote in message ... Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is the VBA explanation for the term NullString:
Returns or sets the string displayed in cells that contain null values when the DisplayNullString property is True. The default value is an empty string (""). Read/write String. "vivmaha" wrote: Hi, I have the following code: Public parent As Node Set parent = New Node parent = Null This doesnt work (Error 438). The error is on the last line, where I try to assign a null value to parent. How do I assign null values to objects in VBA? Btw, "Node" is defined as a class module. Thanks. |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
However, Null is different than the null string (look up Null in VBA
Help) In article , JLGWhiz wrote: This is the VBA explanation for the term NullString: Returns or sets the string displayed in cells that contain null values when the DisplayNullString property is True. The default value is an empty string (""). Read/write String. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Failed to save table attributes of (null) into (null). | Excel Discussion (Misc queries) | |||
whats it do | Excel Discussion (Misc queries) | |||
Null, "null", vbNull, vbNullString, vbEmpty | Excel Programming | |||
I don't get it, Whats going on here? | Excel Programming | |||
Whats the equivalent for NETWORKDAYS in VBA for excel ? | Excel Programming |