Someone shared this with me yersterday. Cool for generating GUIDS in VBScript.
Code:function GetNewGUID()
set TypeLib = server.CreateObject("Scriptlet.TypeLib")
GetNewGUID = TypeLib.Guid
Set TypeLib = nothing
end function
Printable View
Someone shared this with me yersterday. Cool for generating GUIDS in VBScript.
Code:function GetNewGUID()
set TypeLib = server.CreateObject("Scriptlet.TypeLib")
GetNewGUID = TypeLib.Guid
Set TypeLib = nothing
end function
I don't like the ScriptLet typelib that much...Just an opinion....
here's an api-way :
VB Code:
Option Explicit Private Type GUID Data1 As Long Data2 As Integer Data3 As Integer Data4(0 To 7) As Byte End Type Private Declare Function CoCreateGuid Lib "ole32" (pguid As GUID) As Long Private Declare Function UuidToString Lib "rpcrt4" Alias "UuidToStringA" (pguid As GUID, pszGuid As Long) As Long Private Declare Function RpcStringFree Lib "rpcrt4" Alias "RpcStringFreeA" (psz As Long) As Long Private Declare Function CopyLongToString Lib "kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, lpString2 As Any) As Long Public Function CreateGuid() As String Dim TheGuid As GUID Dim pszGuid As Long CoCreateGuid TheGuid UuidToString TheGuid, pszGuid CreateGuid = Space(256) CopyLongToString CreateGuid, ByVal pszGuid RpcStringFree pszGuid CreateGuid = UCase(Mid(CreateGuid, 1, InStr(1, CreateGuid, vbNullChar) - 1)) End Function Private Sub Form_Load() Debug.Print CreateGuid End Sub
Thanks but did you notice I said VBScript? :confused:
Woops... My Mistake...
Sorry :(
no prob :)