473,383 Members | 2,005 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.

GUID

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

Similar topics

4
by: Louis Frolio | last post by:
Greetings All, I have read many upon many articles here regarding GUID data types and uniqueness. There have been many opinions regarding the effectiveness of GUID's and when they should/should...
6
by: Jim Heavey | last post by:
When I use the new(Guid), the GUID which is generated is all zeros. Is there a technique for the system to assign a real Guid? Do I have to manually calculate a 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...
14
by: Nak | last post by:
Hi there, Does anyone know how I would get the value of the assembly GUID in code from within the same application? Thanks in advance. Nick. --...
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...
5
by: George | last post by:
I want to create a unique id for each of a set of objects. These ids may be generated on multiple machines simultaneously and must all be different to each other. There are an undefined number...
1
by: Wolf | last post by:
Hi I am trying to set a property(PartyHomeAddressID) = to a guid in a ini file. But everytime when the ini file has an empty guid it breaks with an error tellin me a guid is 32 char long with 4...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.