1

In a relatively large VB.NET application, I have the following code.

code

The code sits within a for loop that runs for every given service object. I want a conditional break point that will only activate when objService.VehLastMile is Nothing.

So I right-click my break point and add a condition, here it is:

condition

But this does not work! my break point is not hit! what am I doing wrong?

Any help would be great.

Thank You.

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
J86
  • 14,345
  • 47
  • 130
  • 228

2 Answers2

2

The = operator doesn't work for a value of nothing in VB.NET

You should either use the Is operator:

objService.VehLastMile Is Nothing

Or IsNothing function:

IsNothing(objService.VehLastMile)
Alireza
  • 4,976
  • 1
  • 23
  • 36
0

Just like when you are coding, if you want to compare a reference type to Null (Nothing) you have to use Is so your condition should be:

objService.VehLastMile Is Nothing

You can compare value types to nothing using the equals sign, but this is effectively the same as comparing it to [Type].MinValue

See What is the difference between a reference type and value type in c#?

Community
  • 1
  • 1
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143