create GUID
![Visual Basic 6, or VB Classic Visual Basic 6, or VB Classic](https://www.fortypoundhead.com//assets/img/icons/v7/vb6.png)
This program creates a GUID, a unique 128-bit integer used for CLSIDs and interface identifiers.The idea of a GUID is that no two machines can ever generate the same GUID value twice. This is achieved by using a combination of the current time, your machine's Media Access Control (MAC) address (a unique number built into all network cards) if it has one, and other routines.
Original Author: Ruchika
API Declarations
Private Declare Function CoCreateGuid Lib "ole32" (id As Any) As Long
Code
Private Sub Form_Load()
MsgBox "Generated GUID: " + CreateGUID
End Sub
Public Function CreateGUID() As String
Dim id(0 To 15) As Byte
Dim Cnt As Long, GUID As String
If CoCreateGuid(id(0)) = 0 Then
For Cnt = 0 To 15
CreateGUID = CreateGUID + IIf(id(Cnt) < 16, "0", "") + Hex$(id(Cnt))
Next Cnt
CreateGUID = Left$(CreateGUID, 8) + "-" + Mid$(CreateGUID, 9, 4) + "-" + Mid$(CreateGUID, 13, 4) + "-" + Mid$(CreateGUID, 17, 4) + "-" + Right$(CreateGUID, 12)
Else
MsgBox "Error while creating GUID!"
End If
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.