How to Generate a GUID with VB Script

Provided by the FMS Development Team

Global Unique Ids (GUIDs) can be very useful in naming files, folders or database records. GUIDs are guaranteed to be unique irrespective of the origin.

"Scriptlet.Typelib" is an object that is normally used to generate a type library for Windows Script Component dynamically. By design, the object creates a GUID if one is not provided, so this feature is used to create GUIDs.

The following code shows how to create a GUID in Visual Basic Script:

Set x = CreateObject("Scriptlet.TypeLib")
strNewGuid=Left(x.GUID, 38)

In order to generate 5 GUIDs, the following code sample may be used:

For n = 1 to 5
  uniqueid(n) = Left(CreateObject("Scriptlet.Typelib").guid, 38)
Next n


Additional Resources

 

 

Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.

Darren D.


View all FMS products for Microsoft Access All Our Microsoft Access Products

 

 

Free Product Catalog from FMS