Skip to content

Instantly share code, notes, and snippets.

@danwagnerco
Last active October 2, 2016 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danwagnerco/cb809ae5a2f7e194faed9ac7ff5eb71b to your computer and use it in GitHub Desktop.
Save danwagnerco/cb809ae5a2f7e194faed9ac7ff5eb71b to your computer and use it in GitHub Desktop.
This tiny subroutine walks through all of the options available in the CreateGUID function
Option Explicit
Public Sub TestCreateGUID()
'Dim t As Scriptlet.TypeLib <~ error, user type not defined
'Dim t As Scriptlet.IGenScriptletTLib <~ at least compiles
'Debug.Print t.Name <~ error, object or with block variable not set
' i.e. doesn't understand t as a variable
'Debug.Print t.GUID <~ same
'Debug.Print t.AnyOtherListedMethodOnThisObject
Dim GUID As String
GUID = CreateGUID() '<~ default
Debug.Print GUID
'^^ the result of the above looks like this:
'5DC4C0BD-2AD2-4F36-A37D-1851F5B09966
GUID = CreateGUID(IncludeHyphens:=False) '<~ no hyphens here
Debug.Print GUID
'^^ the result of the above looks like this:
'6A5A9CF9E76948859A0666BA1496D7F0
'
'i.e. hyphens removed
GUID = CreateGUID(IncludeBraces:=True) '<~ curly braces on the ends
Debug.Print GUID
'^^ the result of the above looks like this:
'{88B6591C-053D-414E-8447-224704047786}
'
'i.e. curly braces remain
GUID = CreateGUID(IncludeHyphens:=False, IncludeBraces:=True)
Debug.Print GUID
'^^ the result of the above looks like this:
'{88B6591C053D414E8447224704047786}
'
'i.e. curly braces remain but hyphens do not
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment