Results 1 to 3 of 3

Thread: How is this possible?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    How is this possible?

    Hi!

    Please check this screenshot:



    For some reason the guarding if statement is ignored and I had to add a second if to check if curve was nothing, otherwhise it would crash here, when PlotModel.Curve was not initialized. Why is the if not PlotModel is nothing then statement ignored/evaluated incorrectly?

    is it me who is doing something wrong, or is the compiler acting up on me? I have seen this on occation before.


    /H

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: How is this possible?

    Would you please use code tags and post the code here.

    What is PlotModel? Do you have more than one thread running?

    A personal preference of mine is that when checking an object for not noting is to use IsNot.

    Code:
            If Obj IsNot Nothing Then
    
            End If
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: How is this possible?

    The "default" for reference types is Nothing. So FirstOrDefault() returns either the first object that matches its predicate or Nothing. You usually follow it with a check against Nothing, because if you know for sure there is a result you use First() instead.

    (There's also an overload that lets you specify a non-null default, but I can't tell if you called it because I can't scroll a screenshot.)
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width