Questions tagged [nothing]

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.

140 questions
7
votes
3 answers

VB.Net Linq to Entities Null Comparison - 'Is Nothing' or '= Nothing'?

We have several projects in VB.Net, using .Net Framework 4 and Linq to Entities for many of our SQL queries. Moving to EF is a new shift for us (been using it for about 4-6 months) and has the backing of upper management because we can code so much…
user1359018
6
votes
2 answers

How do I use a null value in a double in VB.Net 2010?

Straightforward question: I have a few variables that are doubles. I would like to be able to store a "null" state in them, i.e. I need to be able to represent that the variable doesn't contain valid data. I'd really rather not associate a boolean…
evilspoons
  • 405
  • 2
  • 6
  • 16
6
votes
1 answer

Using Haskell's "Maybe", type declarations [beginner's question]

I've started experimenting with Haskell and have a problem. qqq is a function that should print one string if called with "Nothing" and print other things if called with "Just something". The first attempt seems like working: qqq Nothing = print…
Vi.
  • 37,014
  • 18
  • 93
  • 148
6
votes
2 answers

Isn't there a nicer way to combine multiple `Union{T, Nothing}`

I'm very new to Julia but I've got a some background in Scheme/Rust/F#. Today I wanted to make yesterday's AoC nicer without an explicit number of nested loops. I arrived at this working solution, but I don't like the last if. In the languages…
primfaktor
  • 2,831
  • 25
  • 34
6
votes
2 answers

Under what conditions is inferring Nothing desirable?

In my own code, and on numerous mailing list postings, I've noticed confusion due to Nothing being inferred as the least upper bound of two other types. The answer may be obvious to you*, but I'm lazy, so I'm asking you*: Under what conditions…
Alex Cruise
  • 7,939
  • 1
  • 27
  • 40
6
votes
3 answers

VB.NET Structs and Nothing - problems

I'm having some headaches using Structures and functions that return Nothing in VB.NET. Let me try to explain here with this code: Public Class Form1 Structure Test Dim field1 As String End Structure Private Function Foo() As…
RHaguiuda
  • 3,207
  • 9
  • 37
  • 55
6
votes
2 answers

Difference between adding zero to nothing in Visual Basic.Net?

Why is this different?! Public Class Form1 Public Function MyFunction() As Integer? Return Nothing End Function Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim o As Object = Me MsgBox(TypeName(Me)) '…
Babak A
  • 61
  • 3
5
votes
1 answer

Why does "If Value is Nothing" throw "Object Required (Error 424)"

The following code throws Object Required (Error 424) at the if statement comparing with Nothing independent of the value given. Why? Public Function SqlizeCellValue(ByVal Value As Variant) As Variant If Value Is Nothing Then …
Torsten Knodt
  • 477
  • 1
  • 5
  • 20
5
votes
3 answers

Set VB.NET variable to C#'s null

According to the MSDN entry for Nothing (Visual Basic) Nothing represents the default value of a data type. It has also been noted by some that "...the Nothing keyword is actually equivalent to C#’s default(T) keyword". This has been giving me…
Alex Essilfie
  • 12,339
  • 9
  • 70
  • 108
5
votes
2 answers

Prevent second half of an if statement when first half is null

I have a statement in VB.net that I thought I wrote correctly to prevent the second half from being evaluated. It looks like this: If ((myDataSet2 IsNot Nothing) Or myDataSet2.Tables("CurData").Rows.Count > 0) However it does not skip the second…
George Mikan
  • 135
  • 7
5
votes
2 answers

VB.NET: Is there a way to keep Nothing from defaulting to 0 for number types?

It's really bugging me that the VS 2010 IDE isn't barking at me for trying to pass Nothing through a method parameter that takes an user-defined enum. Instead, it's passing 0 through to the method. c# would never allow this. Is there some…
oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206
4
votes
2 answers

VB check for Null Reference when passing ByRef

I have a function that accepts a String by reference: Function Foo(ByRef input As String) If I call it like this: Foo(Nothing) I want it to do something different than if I call it like this: Dim myString As String = Nothing Foo(myString) Is it…
Brandon Montgomery
  • 6,924
  • 3
  • 48
  • 71
4
votes
2 answers

Set variables to "Nothing" is a good practice?

If I got Dim myRect As Rectangle = New Rectangle(0,0,100,100) Is it necessary or just fine to later do this: myRect = Nothing Or it isn't necessary? Thank you. IF it is necessary, are there other cases it isn't for my variables?
Saturn
  • 17,888
  • 49
  • 145
  • 271
4
votes
2 answers

Understanding of scala.Nothing type

According to the scala specification, scala.Nothing type - buttom for all types. Type "Nothing" exists but instance of Nothing does not exists. How it works: def ??? : Nothing = throw new NoImplementedError def sys.error(message: String): Nothing…
user5607337
4
votes
6 answers

VB.NET - string of nulls

I have a string value read in from a CSV file. The CSV file contains 7 NULL bytes, I have confirmed this by opening it in a hex editor and sure enought there are 7 0x0 bytes in there. This string is causing me pain. In vb.net when I check the strlen…
WizardsSleeve
  • 185
  • 2
  • 4
  • 11
1
2
3
9 10