Tuesday, September 21, 2010

Create Unique ID in VB 6.0/MSAccess

Public Function CreateId() As String

Dim strNewGuid As String

Dim objGUID As Object

'Create Object from wich GUID can be retrived

Set objGUID = CreateObject("Scriptlet.TypeLib")

strNewGuid = Left(objGUID.Guid, 38)

strArray = Split(CStr(strNewGuid), "-")

strNewGuid = strArray(4)

strNewGuid = Trim(Replace(strNewGuid, "}", ""))

'Return GUID

CreateId = strNewGuid

End Function

No comments:

Post a Comment