Excel里生成GUID


Private Declare Function CoCreateGuid Lib "ole32" (id As Any) As Long
    Private 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM