empty GUID from string in VB2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles Hunt

    empty GUID from string in VB2005

    Hi,

    When running this code in VB2003

    Sub guidtest()

    Dim gstring As String

    Dim gid As Guid

    gstring = Guid.NewGuid(). ToString

    gid = New Guid(gstring)

    End Sub

    variable GID gets the correct value derived from gstring - however when i do
    this in VB2005 it doesn't work - i just get an empty GUID - this seems like
    a fairly serious problem so i am assuming i have made some incorrect basic
    assumptions.

    my installation of VS2005 went pretty smoothly from memory and it pretty
    much has default options.

    Can anyone replicate this problem / error?

    is it a bug in VS/VB or .NET?

    I look forward to hearing from anyone with any ideas here as I have spent
    about 10 hours trying to see what I have done wrong.

    best

    Charles



  • Cor Ligthert [MVP]

    #2
    Re: empty GUID from string in VB2005

    Charles,

    Sorry however your code looks so strange in my eyes, probably you mean.

    \\\
    dim gid as Guid = Guid.NewGuid
    dim gstring = gid.ToString
    ///
    Try to avoid using strings as intermediate, you see people do that as well
    with datetime.

    I hope this helps,

    Cor


    Comment

    • Ken Tucker [MVP]

      #3
      Re: empty GUID from string in VB2005

      Hi,

      I added this line after you created gid.

      MessageBox.Show (gstring, gid.ToString)

      I get the same value in the caption and text.



      Ken
      -------
      "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
      news:OO7hmXgNGH A.2644@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Hi,
      >
      > When running this code in VB2003
      >
      > Sub guidtest()
      >
      > Dim gstring As String
      >
      > Dim gid As Guid
      >
      > gstring = Guid.NewGuid(). ToString
      >
      > gid = New Guid(gstring)
      >
      > End Sub
      >
      > variable GID gets the correct value derived from gstring - however when i
      > do
      > this in VB2005 it doesn't work - i just get an empty GUID - this seems
      > like
      > a fairly serious problem so i am assuming i have made some incorrect basic
      > assumptions.
      >
      > my installation of VS2005 went pretty smoothly from memory and it pretty
      > much has default options.
      >
      > Can anyone replicate this problem / error?
      >
      > is it a bug in VS/VB or .NET?
      >
      > I look forward to hearing from anyone with any ideas here as I have spent
      > about 10 hours trying to see what I have done wrong.
      >
      > best
      >
      > Charles
      >
      >
      >[/color]


      Comment

      • Charles Hunt

        #4
        Re: empty GUID from string in VB2005

        Hi,

        Which version of VB did you use? If I use VB2003 it works, if I use VB2005
        it doesn't work.

        best

        Charles


        "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
        news:%23HIfq1gN GHA.3556@TK2MSF TNGP10.phx.gbl. ..[color=blue]
        > Hi,
        >
        > I added this line after you created gid.
        >
        > MessageBox.Show (gstring, gid.ToString)
        >
        > I get the same value in the caption and text.
        >
        >
        >
        > Ken
        > -------
        > "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
        > news:OO7hmXgNGH A.2644@TK2MSFTN GP10.phx.gbl...[color=green]
        >> Hi,
        >>
        >> When running this code in VB2003
        >>
        >> Sub guidtest()
        >>
        >> Dim gstring As String
        >>
        >> Dim gid As Guid
        >>
        >> gstring = Guid.NewGuid(). ToString
        >>
        >> gid = New Guid(gstring)
        >>
        >> End Sub
        >>
        >> variable GID gets the correct value derived from gstring - however when i
        >> do
        >> this in VB2005 it doesn't work - i just get an empty GUID - this seems
        >> like
        >> a fairly serious problem so i am assuming i have made some incorrect
        >> basic
        >> assumptions.
        >>
        >> my installation of VS2005 went pretty smoothly from memory and it pretty
        >> much has default options.
        >>
        >> Can anyone replicate this problem / error?
        >>
        >> is it a bug in VS/VB or .NET?
        >>
        >> I look forward to hearing from anyone with any ideas here as I have spent
        >> about 10 hours trying to see what I have done wrong.
        >>
        >> best
        >>
        >> Charles
        >>
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Charles Hunt

          #5
          Re: empty GUID from string in VB2005

          Hi,

          No my code is intentionally trying to create a GUID from a string.. not the
          other way around. If I try the way you suggest it works fine - but that is
          not the problem I was trying to demonstrate.

          Thanks anyway.

          Charles


          "Cor Ligthert [MVP]" <notmyfirstname @planet.nl> wrote in message
          news:%23TpmqvgN GHA.2336@TK2MSF TNGP12.phx.gbl. ..[color=blue]
          > Charles,
          >
          > Sorry however your code looks so strange in my eyes, probably you mean.
          >
          > \\\
          > dim gid as Guid = Guid.NewGuid
          > dim gstring = gid.ToString
          > ///
          > Try to avoid using strings as intermediate, you see people do that as well
          > with datetime.
          >
          > I hope this helps,
          >
          > Cor
          >
          >[/color]


          Comment

          • Charles Hunt

            #6
            Re: empty GUID from string in VB2005

            Hi,

            hmmm.. actually that does work, but my original post demonstrates a problem
            where the gid object when inspected with a break point shows as "empty" -
            but the .tostring method does infact yield a correct value.

            This is a bit different in VB2003 because gid appears in the debugger
            correctly (or as expected) but not in VB2005 - where it shows up as
            "empty" - is it my installation or have I just made an abvious goof.

            best

            Charles

            "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
            news:%23HIfq1gN GHA.3556@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > Hi,
            >
            > I added this line after you created gid.
            >
            > MessageBox.Show (gstring, gid.ToString)
            >
            > I get the same value in the caption and text.
            >
            >
            >
            > Ken
            > -------
            > "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
            > news:OO7hmXgNGH A.2644@TK2MSFTN GP10.phx.gbl...[color=green]
            >> Hi,
            >>
            >> When running this code in VB2003
            >>
            >> Sub guidtest()
            >>
            >> Dim gstring As String
            >>
            >> Dim gid As Guid
            >>
            >> gstring = Guid.NewGuid(). ToString
            >>
            >> gid = New Guid(gstring)
            >>
            >> End Sub
            >>
            >> variable GID gets the correct value derived from gstring - however when i
            >> do
            >> this in VB2005 it doesn't work - i just get an empty GUID - this seems
            >> like
            >> a fairly serious problem so i am assuming i have made some incorrect
            >> basic
            >> assumptions.
            >>
            >> my installation of VS2005 went pretty smoothly from memory and it pretty
            >> much has default options.
            >>
            >> Can anyone replicate this problem / error?
            >>
            >> is it a bug in VS/VB or .NET?
            >>
            >> I look forward to hearing from anyone with any ideas here as I have spent
            >> about 10 hours trying to see what I have done wrong.
            >>
            >> best
            >>
            >> Charles
            >>
            >>
            >>[/color]
            >
            >[/color]


            Comment

            • Armin Zingler

              #7
              Re: empty GUID from string in VB2005

              "Charles Hunt" <Charles@HuntRA D.NET> schrieb[color=blue]
              > Hi,
              >
              > hmmm.. actually that does work, but my original post demonstrates a
              > problem where the gid object when inspected with a break point shows
              > as "empty" - but the .tostring method does infact yield a correct
              > value.
              >
              > This is a bit different in VB2003 because gid appears in the
              > debugger correctly (or as expected) but not in VB2005 - where it
              > shows up as "empty" - is it my installation or have I just made an
              > abvious goof.[/color]

              You didn't write how you have it displayed in the IDE: Tooltip? Watch
              window? Locals window? The VB 2005 IDE shows all the instance and shared
              members if you extend the tooltip. GUID.Empty is one member. If you look in
              the locals window in VS 2003 and expand the object, it also shows the Empty
              member, but not in the tooltip.


              Armin

              Comment

              • m.posseth

                #8
                Re: empty GUID from string in VB2005


                Just tried this in VB.Net 2003 and VB.Net 2005

                Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                System.EventArg s) Handles Button1.Click

                guidtest()

                End Sub

                Sub guidtest()

                Dim gstring As String

                Dim gid As Guid

                gstring = Guid.NewGuid(). ToString

                gid = New Guid(gstring)

                MsgBox(gid.ToSt ring)

                End Sub


                and it works as expected

                hth

                Michel Posseth [MCP]






                "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
                news:OBXZ7FhNGH A.2336@TK2MSFTN GP12.phx.gbl...[color=blue]
                > Hi,
                >
                > hmmm.. actually that does work, but my original post demonstrates a
                > problem where the gid object when inspected with a break point shows as
                > "empty" - but the .tostring method does infact yield a correct value.
                >
                > This is a bit different in VB2003 because gid appears in the debugger
                > correctly (or as expected) but not in VB2005 - where it shows up as
                > "empty" - is it my installation or have I just made an abvious goof.
                >
                > best
                >
                > Charles
                >
                > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                > news:%23HIfq1gN GHA.3556@TK2MSF TNGP10.phx.gbl. ..[color=green]
                >> Hi,
                >>
                >> I added this line after you created gid.
                >>
                >> MessageBox.Show (gstring, gid.ToString)
                >>
                >> I get the same value in the caption and text.
                >>
                >>
                >>
                >> Ken
                >> -------
                >> "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
                >> news:OO7hmXgNGH A.2644@TK2MSFTN GP10.phx.gbl...[color=darkred]
                >>> Hi,
                >>>
                >>> When running this code in VB2003
                >>>
                >>> Sub guidtest()
                >>>
                >>> Dim gstring As String
                >>>
                >>> Dim gid As Guid
                >>>
                >>> gstring = Guid.NewGuid(). ToString
                >>>
                >>> gid = New Guid(gstring)
                >>>
                >>> End Sub
                >>>
                >>> variable GID gets the correct value derived from gstring - however when
                >>> i do
                >>> this in VB2005 it doesn't work - i just get an empty GUID - this seems
                >>> like
                >>> a fairly serious problem so i am assuming i have made some incorrect
                >>> basic
                >>> assumptions.
                >>>
                >>> my installation of VS2005 went pretty smoothly from memory and it pretty
                >>> much has default options.
                >>>
                >>> Can anyone replicate this problem / error?
                >>>
                >>> is it a bug in VS/VB or .NET?
                >>>
                >>> I look forward to hearing from anyone with any ideas here as I have
                >>> spent
                >>> about 10 hours trying to see what I have done wrong.
                >>>
                >>> best
                >>>
                >>> Charles
                >>>
                >>>
                >>>[/color]
                >>
                >>[/color]
                >
                >[/color]



                Comment

                • Charles Hunt

                  #9
                  Re: empty GUID from string in VB2005

                  Hi,

                  Yes, I think that is where I have become confused. The fact that the local
                  and watch windows don't show the guid value, but do expand to the empty
                  member made me think the guid was empty when in fact it isn't.

                  If I perform the gid.tostring when the code is at a breakpoint it all seems
                  ok. - Intutively i though the watch would display the value of the GUID
                  object - but it doesn't. (or if i try to ?gid in the command window)

                  thanks

                  Charles

                  "Armin Zingler" <az.nospam@free net.de> wrote in message
                  news:%23$Kv4ShN GHA.3408@TK2MSF TNGP14.phx.gbl. ..[color=blue]
                  > "Charles Hunt" <Charles@HuntRA D.NET> schrieb[color=green]
                  >> Hi,
                  >>
                  >> hmmm.. actually that does work, but my original post demonstrates a
                  >> problem where the gid object when inspected with a break point shows
                  >> as "empty" - but the .tostring method does infact yield a correct
                  >> value.
                  >>
                  >> This is a bit different in VB2003 because gid appears in the
                  >> debugger correctly (or as expected) but not in VB2005 - where it
                  >> shows up as "empty" - is it my installation or have I just made an
                  >> abvious goof.[/color]
                  >
                  > You didn't write how you have it displayed in the IDE: Tooltip? Watch
                  > window? Locals window? The VB 2005 IDE shows all the instance and shared
                  > members if you extend the tooltip. GUID.Empty is one member. If you look
                  > in
                  > the locals window in VS 2003 and expand the object, it also shows the
                  > Empty
                  > member, but not in the tooltip.
                  >
                  >
                  > Armin
                  >[/color]


                  Comment

                  • Cor Ligthert [MVP]

                    #10
                    Re: empty GUID from string in VB2005

                    Charles,

                    I tried it in both now, It is working for me exactly the same.

                    \\\
                    Dim gid As Guid = Guid.NewGuid
                    Dim gid2 As Guid = New Guid(gid.ToStri ng)
                    ///


                    Cor


                    Comment

                    • Charles Hunt

                      #11
                      Re: empty GUID from string in VB2005

                      Hi,

                      The problem I had was that in the watch window is doesn't show any value -
                      which made me think it was unassigned or empty. this is still puzzling me
                      but I will try accept it as "the way it is"

                      best

                      Charles


                      "m.posseth" <michelp@nohaus ystems.nl> wrote in message
                      news:%23cJQnVhN GHA.3788@TK2MSF TNGP09.phx.gbl. ..[color=blue]
                      >
                      > Just tried this in VB.Net 2003 and VB.Net 2005
                      >
                      > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
                      > System.EventArg s) Handles Button1.Click
                      >
                      > guidtest()
                      >
                      > End Sub
                      >
                      > Sub guidtest()
                      >
                      > Dim gstring As String
                      >
                      > Dim gid As Guid
                      >
                      > gstring = Guid.NewGuid(). ToString
                      >
                      > gid = New Guid(gstring)
                      >
                      > MsgBox(gid.ToSt ring)
                      >
                      > End Sub
                      >
                      >
                      > and it works as expected
                      >
                      > hth
                      >
                      > Michel Posseth [MCP]
                      >
                      >
                      >
                      >
                      >
                      >
                      > "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
                      > news:OBXZ7FhNGH A.2336@TK2MSFTN GP12.phx.gbl...[color=green]
                      >> Hi,
                      >>
                      >> hmmm.. actually that does work, but my original post demonstrates a
                      >> problem where the gid object when inspected with a break point shows as
                      >> "empty" - but the .tostring method does infact yield a correct value.
                      >>
                      >> This is a bit different in VB2003 because gid appears in the debugger
                      >> correctly (or as expected) but not in VB2005 - where it shows up as
                      >> "empty" - is it my installation or have I just made an abvious goof.
                      >>
                      >> best
                      >>
                      >> Charles
                      >>
                      >> "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
                      >> news:%23HIfq1gN GHA.3556@TK2MSF TNGP10.phx.gbl. ..[color=darkred]
                      >>> Hi,
                      >>>
                      >>> I added this line after you created gid.
                      >>>
                      >>> MessageBox.Show (gstring, gid.ToString)
                      >>>
                      >>> I get the same value in the caption and text.
                      >>>
                      >>>
                      >>>
                      >>> Ken
                      >>> -------
                      >>> "Charles Hunt" <Charles@HuntRA D.NET> wrote in message
                      >>> news:OO7hmXgNGH A.2644@TK2MSFTN GP10.phx.gbl...
                      >>>> Hi,
                      >>>>
                      >>>> When running this code in VB2003
                      >>>>
                      >>>> Sub guidtest()
                      >>>>
                      >>>> Dim gstring As String
                      >>>>
                      >>>> Dim gid As Guid
                      >>>>
                      >>>> gstring = Guid.NewGuid(). ToString
                      >>>>
                      >>>> gid = New Guid(gstring)
                      >>>>
                      >>>> End Sub
                      >>>>
                      >>>> variable GID gets the correct value derived from gstring - however when
                      >>>> i do
                      >>>> this in VB2005 it doesn't work - i just get an empty GUID - this seems
                      >>>> like
                      >>>> a fairly serious problem so i am assuming i have made some incorrect
                      >>>> basic
                      >>>> assumptions.
                      >>>>
                      >>>> my installation of VS2005 went pretty smoothly from memory and it
                      >>>> pretty
                      >>>> much has default options.
                      >>>>
                      >>>> Can anyone replicate this problem / error?
                      >>>>
                      >>>> is it a bug in VS/VB or .NET?
                      >>>>
                      >>>> I look forward to hearing from anyone with any ideas here as I have
                      >>>> spent
                      >>>> about 10 hours trying to see what I have done wrong.
                      >>>>
                      >>>> best
                      >>>>
                      >>>> Charles
                      >>>>
                      >>>>
                      >>>>
                      >>>
                      >>>[/color]
                      >>
                      >>[/color]
                      >
                      >
                      >[/color]


                      Comment

                      Working...