LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default How do I get a Function to return Null?

The Null value can only be assigned to Variants, not to ranges.
The use of the Null variable is, that it propagates through expressions
(like the value "infinity"). The expression rRow = NULL sets all the
values in the range rRow to NULL. An object can never be set to NULL.
Only a Variant can be either assigned the value NULL or set to an
object or Nothing. So if you declare rRow as a Variant instead of a
range it might even work, although I would not consider it very
elegant.

Example

Definition of class Dirty :

Private rRow As Variant

Public Property Get GetRow() As Range
If IsNull(rRow) Then
Set GetRow = Nothing
Else
Set GetRow = rRow
End If
End Property

Public Property Let SetRow(r As Integer)
If r =< 0 Then
rRow = Null
Else
Set rRow = Rows(r)
End If
End Property

Public Property Get Value() As Variant
Value = rRow
End Property

Main module:

Sub P()
Dim V As Dirty

Set V = New Dirty
V.SetRow = 0
If IsNull(V.Value) Then
MsgBox "NULL"
Else
V.GetRow.Select
End If

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Function -- Return Null Value Help Amanda[_9_] Excel Worksheet Functions 2 January 26th 12 04:44 PM
Return null Karen Excel Worksheet Functions 3 June 11th 08 08:43 AM
how to get a function to return a null value that passes the ISBL. Hawk Excel Worksheet Functions 7 March 5th 08 05:59 AM
Compare Value in Cell 1 to a List, Return Value if Match otherwise Return Null Ben Excel Discussion (Misc queries) 2 March 15th 07 01:02 AM
Can a function return a Null (blank ) value? Maybe a custom functi colin_e Excel Worksheet Functions 2 March 16th 06 02:36 PM


All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"