VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Generate UUID

by alexk (9 Submissions)
Category: VB function enhancement
Difficulty: Intermediate
Date Added: Sun 7th February 2021
Rating: (1 Votes)

A universally unique identifier (UUID). A UUID is a 128-bit number used to identify information in computer systems.

Rate Generate UUID

Function UUID()
   Dim i, RndNum
   For i = 0 to 7
      RndNum = CLng(rnd * "&HFFFF")
     'if i = 0 then RndNum = RndNum Xor (CLng(Date) And "&HFFFF")
      If i = 3 Then RndNum = (RndNum And "&HFFF") Or "&H4000"
      If i = 4 Then RndNum = (RndNum And "&H3FFF") Or "&H8000"
      UUID = UUID + String(4 - Len(Hex(RndNum)), "0") + LCase(Hex(RndNum))
      If i=1 Or i=2 Or i=3 Or i=4 Then UUID = UUID + "-"
   Next
End Function

Download this snippet    Add to My Saved Code

Generate UUID Comments

No comments have been posted about Generate UUID. Why not be the first to post a comment about Generate UUID.

Post your comment

Subject:
Message:
0/1000 characters