为什么这个 VBA 函数会在字符串末尾打印出随机垃圾?
Public Function GenGuid() As String
Dim TypeLib As Object
Dim Guid As String
Set TypeLib = CreateObject("Scriptlet.TypeLib")
Guid = TypeLib.Guid
' format is {24DD18D4-C902-497F-A64B-28B2FA741661}
Guid = Replace(Guid, "{", "")
Guid = Replace(Guid, "}", "")
'Guid = Replace(Guid, "-", "")
GenGuid = Guid
End Function
print genguid()
816BF7CB-68B9-4D6B-855B-1273F22063DB 6
print genguid()
53664789-B0CD-422C-87B4-8928D93E5078
print genguid()
FDD8ABDE-41F1-45E0-8330-9BA6161873BE i
参考
版本
Excel 2007