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

GUID

P: n/a
Is there a built in function for creating a Guid in VB .Net ?
I know about the CoCreateGuid API call, but I though that maybe it's been
built in to .Net ?

I've found the GUID class and tried

Dim oGuid as New Guid
Dim sGuid = oGuid.NewGuid()

But it gives me a blank GUID (string of zeros)

Thanks

Gary

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Gary Dunne" <Ke*****************@zarion.com.deletethis> schrieb:
Is there a built in function for creating a Guid in VB .Net ?
[...]
I've found the GUID class and tried

Dim oGuid as New Guid
Dim sGuid = oGuid.NewGuid()

But it gives me a blank GUID (string of zeros)


Notice that 'NewGuid' is a shared method of the 'Guid' class:

\\\
MsgBox(Guid.NewGuid().ToString())
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #2

P: n/a
Gary,
As Herfried stated, NewGuid is a shared method, it returns a new Guid for
you. Guid is a structure, calling the Guid's constructor with "New Guid"
does not actually create a Guid.

Use something like:
Dim oGuid as Guid = Guid.NewGuid()
Dim sGuid As String = oGuid.ToString()
Hope this helps
Jay
"Gary Dunne" <Ke*****************@zarion.com.deletethis> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl... Is there a built in function for creating a Guid in VB .Net ?
I know about the CoCreateGuid API call, but I though that maybe it's been
built in to .Net ?

I've found the GUID class and tried

Dim oGuid as New Guid
Dim sGuid = oGuid.NewGuid()

But it gives me a blank GUID (string of zeros)

Thanks

Gary

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.