Posted By

keidash on 07/27/10


Tagged

vb6 guid


Versions (?)

How to create a GUID Type on VB6


 / Published in: Visual Basic
 

How to create a GUID Type on VB6

  1. Private Type GUID
  2. Data1 As Long
  3. Data2 As Integer
  4. Data3 As Integer
  5. Data4(7) As Byte
  6. End Type
  7.  
  8. Private Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As
  9. Long
  10.  
  11. Public Function GetGUID() As String
  12. '(c) 2000 Gus Molina
  13.  
  14. Dim udtGUID As GUID
  15.  
  16. If (CoCreateGuid(udtGUID) = 0) Then
  17.  
  18. GetGUID = _
  19. String(8 - Len(Hex$(udtGUID.Data1)), "0") & Hex$(udtGUID.Data1) & _
  20. String(4 - Len(Hex$(udtGUID.Data2)), "0") & Hex$(udtGUID.Data2) & _
  21. String(4 - Len(Hex$(udtGUID.Data3)), "0") & Hex$(udtGUID.Data3) & _
  22. IIf((udtGUID.Data4(0) < &H10), "0", "") & Hex$(udtGUID.Data4(0)) & _
  23. IIf((udtGUID.Data4(1) < &H10), "0", "") & Hex$(udtGUID.Data4(1)) & _
  24. IIf((udtGUID.Data4(2) < &H10), "0", "") & Hex$(udtGUID.Data4(2)) & _
  25. IIf((udtGUID.Data4(3) < &H10), "0", "") & Hex$(udtGUID.Data4(3)) & _
  26. IIf((udtGUID.Data4(4) < &H10), "0", "") & Hex$(udtGUID.Data4(4)) & _
  27. IIf((udtGUID.Data4(5) < &H10), "0", "") & Hex$(udtGUID.Data4(5)) & _
  28. IIf((udtGUID.Data4(6) < &H10), "0", "") & Hex$(udtGUID.Data4(6)) & _
  29. IIf((udtGUID.Data4(7) < &H10), "0", "") & Hex$(udtGUID.Data4(7))
  30. End If
  31.  
  32. End Function

Report this snippet  

You need to login to post a comment.