VB 2005, immediate window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Armin Zingler

    VB 2005, immediate window

    Hi,

    I feel fooled.. In the immediate window, if I enter

    ? DateTime.Now.Ki nd

    I get "Unspecifie d {0}". The result - I expected "local" - lead to some time
    consuming deliberations. Today, I execute

    MsgBox(DateTime .Now.Kind)
    MsgBox(DateTime .Now.Kind.ToStr ing)

    as part of the source code, and I get "2" and "local" (where 2 = local, so
    this is consistent).

    Why does the immediate window lie? There, If I execute

    ?DateTime.Now.K ind.ToString

    I even get the message "Run-time exception thrown :
    System.Argument Exception - Cannot find the method on the object instance."

    What? Did I overlook anything?


    Armin

  • Mr. Arnold

    #2
    Re: VB 2005, immediate window


    "Armin Zingler" <az.nospam@free net.dewrote in message
    news:udyqeWysHH A.4572@TK2MSFTN GP02.phx.gbl...
    Hi,
    >
    I feel fooled.. In the immediate window, if I enter
    >
    ? DateTime.Now.Ki nd
    >
    I get "Unspecifie d {0}". The result - I expected "local" - lead to some
    time
    consuming deliberations. Today, I execute
    >
    MsgBox(DateTime .Now.Kind)
    MsgBox(DateTime .Now.Kind.ToStr ing)
    >
    as part of the source code, and I get "2" and "local" (where 2 = local, so
    this is consistent).
    >
    Why does the immediate window lie? There, If I execute
    >
    ?DateTime.Now.K ind.ToString
    >
    I even get the message "Run-time exception thrown :
    System.Argument Exception - Cannot find the method on the object instance."
    >
    What? Did I overlook anything?
    The fact that you cannot issue that statement like that, because it needs an
    object to work with to complete the statement.

    dim strhldkind as string

    strhldkind = datetime.now.ki nd.tostring

    Now, after executing that statement in code, the *strhldkind* is now an
    *object* and in the immediate window you can enter this.

    ?strhldkind

    It will show *local*

    or you could have done this in code

    dim strhldkind as string = datetime.now.ki nd.tostring

    Comment

    • Armin Zingler

      #3
      Re: VB 2005, immediate window

      "Mr. Arnold" <MR. Arnold@Arnold.c omschrieb
      >
      "Armin Zingler" <az.nospam@free net.dewrote in message
      news:udyqeWysHH A.4572@TK2MSFTN GP02.phx.gbl...
      Hi,

      I feel fooled.. In the immediate window, if I enter

      ? DateTime.Now.Ki nd

      I get "Unspecifie d {0}". The result - I expected "local" - lead to
      some time
      consuming deliberations. Today, I execute

      MsgBox(DateTime .Now.Kind)
      MsgBox(DateTime .Now.Kind.ToStr ing)

      as part of the source code, and I get "2" and "local" (where 2 =
      local, so this is consistent).

      Why does the immediate window lie? There, If I execute

      ?DateTime.Now.K ind.ToString

      I even get the message "Run-time exception thrown :
      System.Argument Exception - Cannot find the method on the object
      instance."

      What? Did I overlook anything?
      >
      The fact that you cannot issue that statement like that, because it
      needs an object to work with to complete the statement.
      It is a complete statement. The result of the ToString method *is* an
      object, it's a String. The "?" (aka print) command prints strings like they
      are. It can take any expression as an argument, be it one simple variable
      like strhldkind or be it a more complex expression. It does work with
      "?datetime.now. kind", so why shouldn't it work with one more ".tostring" ?
      Just because it's one more dot? This doesn't make sense.

      Or, why does, for example,
      "?System.Window s.Forms.Screen. PrimaryScreen.B itsPerPixel" work as well as
      "?System.Window s.Forms.Screen. PrimaryScreen.B itsPerPixel.ToS tring"?
      without an exception?
      dim strhldkind as string
      >
      strhldkind = datetime.now.ki nd.tostring
      >
      Now, after executing that statement in code, the *strhldkind* is now
      an *object* and in the immediate window you can enter this.
      >
      ?strhldkind
      >
      It will show *local*
      >
      or you could have done this in code
      >
      dim strhldkind as string = datetime.now.ki nd.tostring

      Well, the problem is that it should also work like I explained before.

      In addition, it is still wrong that it outputs "unspecifie d" in the
      immediate window whereas I get "local" in the code.


      Armin

      Comment

      • Chris Dunaway

        #4
        Re: VB 2005, immediate window

        On Jun 20, 11:22 pm, "Armin Zingler" <az.nos...@free net.dewrote:
        "Mr. Arnold" <MR. Arn...@Arnold.c omschrieb
        >
        >
        >
        >
        >
        "Armin Zingler" <az.nos...@free net.dewrote in message
        news:udyqeWysHH A.4572@TK2MSFTN GP02.phx.gbl...
        Hi,
        >
        I feel fooled.. In the immediate window, if I enter
        >
        ? DateTime.Now.Ki nd
        >
        I get "Unspecifie d {0}". The result - I expected "local" - lead to
        some time
        consuming deliberations. Today, I execute
        >
        MsgBox(DateTime .Now.Kind)
        MsgBox(DateTime .Now.Kind.ToStr ing)
        >
        as part of the source code, and I get "2" and "local" (where 2 =
        local, so this is consistent).
        >
        Why does the immediate window lie? There, If I execute
        >
        ?DateTime.Now.K ind.ToString
        >
        I even get the message "Run-time exception thrown :
        System.Argument Exception - Cannot find the method on the object
        instance."
        >
        What? Did I overlook anything?
        >
        The fact that you cannot issue that statement like that, because it
        needs an object to work with to complete the statement.
        >
        It is a complete statement. The result of the ToString method *is* an
        object, it's a String. The "?" (aka print) command prints strings like they
        are. It can take any expression as an argument, be it one simple variable
        like strhldkind or be it a more complex expression. It does work with
        "?datetime.now. kind", so why shouldn't it work with one more ".tostring" ?
        Just because it's one more dot? This doesn't make sense.
        >
        Or, why does, for example,
        "?System.Window s.Forms.Screen. PrimaryScreen.B itsPerPixel" work as well as
        "?System.Window s.Forms.Screen. PrimaryScreen.B itsPerPixel.ToS tring"?
        without an exception?
        >
        dim strhldkind as string
        >
        strhldkind = datetime.now.ki nd.tostring
        >
        Now, after executing that statement in code, the *strhldkind* is now
        an *object* and in the immediate window you can enter this.
        >
        ?strhldkind
        >
        It will show *local*
        >
        or you could have done this in code
        >
        dim strhldkind as string = datetime.now.ki nd.tostring
        >
        Well, the problem is that it should also work like I explained before.
        >
        In addition, it is still wrong that it outputs "unspecifie d" in the
        immediate window whereas I get "local" in the code.
        >
        Armin
        I'm inclined to believe it is a bug. Because it displays properly in
        the Immediate window when using C#, but I get the same results you do
        when using VB.

        Chris

        Comment

        • Armin Zingler

          #5
          Re: VB 2005, immediate window

          "Chris Dunaway" <dunawayc@gmail .comschrieb
          Well, the problem is that it should also work like I explained
          before.

          In addition, it is still wrong that it outputs "unspecifie d" in
          the immediate window whereas I get "local" in the code.

          Armin
          >
          I'm inclined to believe it is a bug. Because it displays properly
          in the Immediate window when using C#, but I get the same results
          you do when using VB.
          ...forwarded:





          Armin

          Comment

          Working...