GUIDS not creating correctly in vb.net

D

doug

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.
 
T

Tom Leylan

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top