473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 4345
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
9
by: Rene | last post by:
I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000") to represent a special meaning. The problem is that I don't know if there is a chance that a command like...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
1
by: Scott M. Lyon | last post by:
I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter...
1
by: Scott M. Lyon | last post by:
I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter...
2
by: csharper | last post by:
Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty ?
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
2
by: Troll | last post by:
Windows XP Pro VS 2005 & C# (I'm fairly new to C# but have doing VB.Net going on 2yrs and VB6 for 5yrs.) I'm using C# to build a custom RSS generator. I'm having trouble building the guid...
4
by: Marc | last post by:
Hi, I don't get it I cannot get this to work, can somebody give me a hint Table1 contains a field Id which is a GUID as primary key and DATA a string, I want to insert a new row but it does not...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.