By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,572 Members | 1,516 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,572 IT Pros & Developers. It's quick & easy.

GUIDS not creating correctly in vb.net

P: n/a
G'day all,

I'm a newbie to .net (7 years or so as a vb/asp programmer) and I'm
trying to create a GUID using the GUID type in vb.net

Here's the code I'm using to create it :

Public Function CreateGUID() As String
Dim objGUID As Object
objGUID = New Guid
CreateGUID = objGUID.ToString
End Function

This function returns to me a formatted string that kinda looks like a
GUID, but it is all zeros - can anyone help?

Cheers,

Doug.

Nov 11 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Note that you declared the variable as type Object (but that's not it.)
You've created a blank GUID so you're seeing zeros.

Instead of a separate function try putting this in place of the call to your
function.

Dim s As String
s = Guid.NewGuid.ToString

Don't even need to instantiate a Guid object to get it.

Tom
<do**@dodeonline.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
G'day all,

I'm a newbie to .net (7 years or so as a vb/asp programmer) and I'm
trying to create a GUID using the GUID type in vb.net

Here's the code I'm using to create it :

Public Function CreateGUID() As String
Dim objGUID As Object
objGUID = New Guid
CreateGUID = objGUID.ToString
End Function

This function returns to me a formatted string that kinda looks like a
GUID, but it is all zeros - can anyone help?

Cheers,

Doug.

Nov 11 '06 #2

P: n/a
Thanks Tom - that worked a treat :)

Cheers,

Doug.
Tom Leylan wrote:
Note that you declared the variable as type Object (but that's not it.)
You've created a blank GUID so you're seeing zeros.

Instead of a separate function try putting this in place of the call to your
function.

Dim s As String
s = Guid.NewGuid.ToString

Don't even need to instantiate a Guid object to get it.

Tom
<do**@dodeonline.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
G'day all,

I'm a newbie to .net (7 years or so as a vb/asp programmer) and I'm
trying to create a GUID using the GUID type in vb.net

Here's the code I'm using to create it :

Public Function CreateGUID() As String
Dim objGUID As Object
objGUID = New Guid
CreateGUID = objGUID.ToString
End Function

This function returns to me a formatted string that kinda looks like a
GUID, but it is all zeros - can anyone help?

Cheers,

Doug.
Nov 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.