Create a GUID (Globally Unique ID)
GUIDs are an odd-looking series of numbers and characters, such as: {05589FA1-C356-11CE-BF01-00AA0055595A}. You might expect that GUIDs, because they're how COM distinguishes between objects, would be easy to create in classic VB, which depends on COM. And you might expect that they'd be harder to create in VB.NET, which doesn't depend on them. So much for expectations.
Classic VB:
Private Declare Function CoCreateGuid Lib _
"ole32.dll" (buffer As Byte) As Long
Private Declare Function StringFromGUID2 Lib _
"ole32.dll" (buffer As Byte, ByVal lpsz As Long, _
ByVal cbMax As Long) As Long
Private Function getGUID() As String
Dim buffer(15) As Byte
Dim s As String
Dim ret As Long
s = String$(128, 0)
ret = CoCreateGuid(buffer(0))
ret = StringFromGUID2(buffer(0), StrPtr(s), 128)
getGUID = Left$(s, ret - 1)
End Function
VB.NET Private Function getGUID() As String
GetGUID = "{" & _
System.Guid.NewGUID().ToString & "}"
End Function