In VB.NET, Nothing refers to something which has not been initialized. In C# it would be null. Occasionally used in the Scala type system.
Questions tagged [nothing]
140 questions
                    
                    134
                    
            votes
                
                8 answers
            
        IsNothing versus Is Nothing
Does anyone here use VB.NET and have a strong preference for or against using IsNothing as opposed to Is Nothing (for example, If IsNothing(anObject) or If anObject Is Nothing...)?  If so, why?
EDIT: If you think they're both equally acceptable, do…
        
        Luke Girvin
        
- 13,221
 - 9
 - 64
 - 84
 
                    88
                    
            votes
                
                8 answers
            
        Why can't I check if a 'DateTime' is 'Nothing'?
In VB.NET, is there a way to set a DateTime variable to "not set"? And why is it possible to set a DateTime to Nothing, but not possible to check if it is Nothing? For example:
Dim d As DateTime = Nothing
Dim boolNotSet As Boolean = d Is Nothing…
        
        Muleskinner
        
- 14,150
 - 19
 - 58
 - 79
 
                    49
                    
            votes
                
                5 answers
            
        "Not ... Is Nothing" versus "... IsNot Nothing"
Does anyone here use VB.NET and have a strong preference for or against using Not foo Is Nothing as opposed to foo IsNot Nothing? If so, why?
For Example
If var1 IsNot Nothing Then
...
End If
and
If Not var1 Is Nothing Then
...
End If
I just want…
        
        nnnn
        
- 1,041
 - 3
 - 18
 - 35
 
                    31
                    
            votes
                
                3 answers
            
        Error checking for NULL in VBScript
I have the following VBScript in a Classic ASP page:
function getMagicLink(fromWhere, provider)
    dim url 
    url = "magic.asp?fromwhere=" & fromWhere
    If Not provider is Nothing Then ' Error occurs here
        url = url & "&provider=" &…
        
        Vivian River
        
- 31,198
 - 62
 - 198
 - 313
 
                    28
                    
            votes
                
                4 answers
            
        Nothing = String.Empty (Why are these equal?)
Why does the first if statement evaluate to true?  I know if I use "is" instead of "=" then it won't evaluate to true.  If I replace String.Empty with "Foo" it doesn't evaluate to true.  Both String.Empty and "Foo" have the same type of String, so…
        
        Justin Helgerson
        
- 24,900
 - 17
 - 97
 - 124
 
                    26
                    
            votes
                
                3 answers
            
        VBA: Conditional - Is Nothing
There is an If condition in a VBA application as seen below:
If Not My_Object Is Nothing Then
My_Object.Compute
When the code is run in debug mode, I found that the If condition returns a true even when My_Object has "No Variables".
Could somebody…
        
        StarDotStar
        
- 2,865
 - 3
 - 20
 - 15
 
                    24
                    
            votes
                
                7 answers
            
        How to tell whether a variable has been initialized in C#?
I know this is a dumb question and I guess it must have been asked before. However I am unable to find an answer to my question.
Here is some sample code (which of course does not compile) to outline my problem:
class test
{
     int[] val1;
    …
        
        niklasfi
        
- 15,245
 - 7
 - 40
 - 54
 
                    23
                    
            votes
                
                5 answers
            
        C# vs VB.NET - Handling of null Structures
I ran across this and was wondering if someone could explain why this works in VB.NET when I would expect it should fail, just like it does in C#
//The C# Version
struct Person {
    public string name;
}
...
Person someone = null; //Nope! Can't do…
        
        hugoware
        
- 35,731
 - 24
 - 60
 - 70
 
                    16
                    
            votes
                
                3 answers
            
        If the Nothing type is at the bottom of the class hierarchy, why can I not call any conceivable method on it?
The scala type Nothing represents (as I understand it) the bottom of the type hierarchy, also denoted by the symbol ⊥. That is, Nothing is a sub-type of any given type. The requirement for a Nothing type is explained well by James Iry for those of…
        
        oxbow_lakes
        
- 133,303
 - 56
 - 317
 - 449
 
                    13
                    
            votes
                
                3 answers
            
        vb.net Boolean and Nothing
Let's define this function :
Public Function Test(ByVal value As Boolean)
    Return "blabla" + If(value = Nothing, "", If(value, "1", "0"))
End Function
I want it to do the following : 
Test(True) -> "blabla1", Test(False) -> "blabla0",…
        
        Arthur Rey
        
- 2,990
 - 3
 - 19
 - 42
 
                    11
                    
            votes
                
                1 answer
            
        Comparing Julia variable to `nothing` using !== or !=
In some Julia code when can see conditional expression such as
if val !== nothing
    dosomething()
end
where val is a variable of type Union{Int,Nothing}
What is the difference between conditons val !== nothing and val != nothing?
        
        scls
        
- 16,591
 - 10
 - 44
 - 55
 
                    9
                    
            votes
                
                2 answers
            
        VB Nullables and Nothings
I researched C#'s default keyword equivalence in VB.NET and came across this question.
Then I got curious.  Some background - I'm working with parsing an excel spreadsheet, where many columns can be null, and there is certainly a difference for me…
        
        Jonesopolis
        
- 25,034
 - 12
 - 68
 - 112
 
                    8
                    
            votes
                
                4 answers
            
        F# Conditional Expressions if...then..else returning unit or ()
F#'s Condtional Expressions require a condition to check, a branch for true, and a branch for false. For example:
let x = 
    if ("hello" = null) 
    then true
    else false //error if else branch missing
However, something gets weird when unit,…
        
        Brett Rowberry
        
- 1,030
 - 8
 - 21
 
                    7
                    
            votes
                
                1 answer
            
        find if `find` method returns `nothing` in excel vba
I'm trying to find an id in a list and get it's address, but also deal with a situation if nothing is found.
Here's what I have:
Function find_in_two_ranges_two_sheets(ws1 As String, col1 As Integer) As Range
    Dim rows1 As Integer
    rows1 =…
        
        DBWeinstein
        
- 8,605
 - 31
 - 73
 - 118
 
                    7
                    
            votes
                
                4 answers
            
        Why do some Scala methods use polymorphic arguments instead of using Any/Nothing?
For example, Exception.allCatch is defined as
def allCatch[T]: Catch[T] 
Why not just
val allCatch: Catch[Nothing]
when Catch is covariant in its argument?
Or, why PartialFunction object defines
def empty[A, B]: PartialFunction[A, B] 
instead of…
        
        Petr
        
- 62,528
 - 13
 - 153
 - 317