469,609 Members | 1,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

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

Feb 20 '06 #1
10 4160
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
Feb 20 '06 #2
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" <Ch*****@HuntRAD.NET> wrote in message
news:OO**************@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

Feb 20 '06 #3
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]" <vb***@bellsouth.net> wrote in message
news:%2****************@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" <Ch*****@HuntRAD.NET> wrote in message
news:OO**************@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


Feb 20 '06 #4
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]" <no************@planet.nl> wrote in message
news:%2****************@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

Feb 20 '06 #5
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:%2****************@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" <Ch*****@HuntRAD.NET> wrote in message
news:OO**************@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


Feb 20 '06 #6
"Charles Hunt" <Ch*****@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

Feb 20 '06 #7

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" <Ch*****@HuntRAD.NET> wrote in message
news:OB**************@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:%2****************@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" <Ch*****@HuntRAD.NET> wrote in message
news:OO**************@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




Feb 20 '06 #8
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*******@freenet.de> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
"Charles Hunt" <Ch*****@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

Feb 20 '06 #9
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
Feb 20 '06 #10
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" <mi*****@nohausystems.nl> wrote in message
news:%2****************@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" <Ch*****@HuntRAD.NET> wrote in message
news:OB**************@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:%2****************@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" <Ch*****@HuntRAD.NET> wrote in message
news:OO**************@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




Feb 20 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Rene | last post: by
1 post views Thread by Scott M. Lyon | last post: by
1 post views Thread by Scott M. Lyon | last post: by
5 posts views Thread by Michael Primeaux | last post: by
4 posts views Thread by Marc | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.