Home All Groups Group Topic Archive Search About

empty GUID from string in VB2005

Author
20 Feb 2006 9:48 AM
Charles Hunt
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

Author
20 Feb 2006 10:55 AM
Cor Ligthert [MVP]
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
Author
20 Feb 2006 11:23 AM
Charles Hunt
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


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23TpmqvgNGHA.2336@TK2MSFTNGP12.phx.gbl...
> 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
>
>
Author
20 Feb 2006 12:24 PM
Cor Ligthert [MVP]
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.ToString)
///


Cor
Author
20 Feb 2006 11:04 AM
Ken Tucker [MVP]
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
-------
Show quoteHide quote
"Charles Hunt" <Char***@HuntRAD.NET> wrote in message
news:OO7hmXgNGHA.2644@TK2MSFTNGP10.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
>
>
>
Author
20 Feb 2006 11:22 AM
Charles Hunt
Hi,

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

best

Charles


Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl...
> 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" <Char***@HuntRAD.NET> wrote in message
> news:OO7hmXgNGHA.2644@TK2MSFTNGP10.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
>>
>>
>>
>
>
Author
20 Feb 2006 11:33 AM
Charles Hunt
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

Show quoteHide quote
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl...
> 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" <Char***@HuntRAD.NET> wrote in message
> news:OO7hmXgNGHA.2644@TK2MSFTNGP10.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
>>
>>
>>
>
>
Author
20 Feb 2006 11:56 AM
Armin Zingler
"Charles Hunt" <Char***@HuntRAD.NET> schrieb
> 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.

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
Author
20 Feb 2006 12:22 PM
Charles Hunt
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

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:%23$Kv4ShNGHA.3408@TK2MSFTNGP14.phx.gbl...
> "Charles Hunt" <Char***@HuntRAD.NET> schrieb
>> 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.
>
> 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
>
Author
20 Feb 2006 12:01 PM
m.posseth
Just tried this in VB.Net 2003 and VB.Net 2005

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.ToString)

End Sub


and it works as expected

hth

Michel Posseth [MCP]






Show quoteHide quote
"Charles Hunt" <Char***@HuntRAD.NET> wrote in message
news:OBXZ7FhNGHA.2336@TK2MSFTNGP12.phx.gbl...
> 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]" <vb***@bellsouth.net> wrote in message
> news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl...
>> 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" <Char***@HuntRAD.NET> wrote in message
>> news:OO7hmXgNGHA.2644@TK2MSFTNGP10.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
>>>
>>>
>>>
>>
>>
>
>
Author
20 Feb 2006 12:24 PM
Charles Hunt
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


Show quoteHide quote
"m.posseth" <mich***@nohausystems.nl> wrote in message
news:%23cJQnVhNGHA.3788@TK2MSFTNGP09.phx.gbl...
>
> Just tried this in VB.Net 2003 and VB.Net 2005
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) 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.ToString)
>
> End Sub
>
>
> and it works as expected
>
> hth
>
> Michel Posseth [MCP]
>
>
>
>
>
>
> "Charles Hunt" <Char***@HuntRAD.NET> wrote in message
> news:OBXZ7FhNGHA.2336@TK2MSFTNGP12.phx.gbl...
>> 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]" <vb***@bellsouth.net> wrote in message
>> news:%23HIfq1gNGHA.3556@TK2MSFTNGP10.phx.gbl...
>>> 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" <Char***@HuntRAD.NET> wrote in message
>>> news:OO7hmXgNGHA.2644@TK2MSFTNGP10.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
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
>