Thursday, May 11, 2006

Generating a GUID

Q: How can I create a unique value without using a counter?

A: The .Net framework provides a method for generating a universally unique identifier or GUID and can be accessed as shown below:

Dim strGUID as String = System.GUID.NewGuid().ToString()

GUID is short for Globaly Unique Identifier. This number is
based on IP address, MAC address, and date/time. It's represented as a series of alpha-numeric characters in the format {8-4-4-4-12}.

Using the NewGuid() method allows unique numbers to be generated by one function call, without concern for repeating identifiers or counters.

No comments: