Outputting a GUID in VBScript ignores all text after it

﹥>﹥吖頭↗ 提交于 2019-12-04 23:44:59

I seem to have solved my own problem.. it was adding something extra to the text, so I had to do:

myGuid = Left(myGuid, Len(myGuid)-2)

and it now outputs fine. Strange.

I use something like this

Function GetGuid() 
        Set TypeLib = CreateObject("Scriptlet.TypeLib") 
        GetGuid = Left(CStr(TypeLib.Guid), 38) 
        Set TypeLib = Nothing 
End Function 

It adds a vbNullChar or Chr(0) at the end of the GUID. Replace(myGuid, Chr(0), "") will fix it. Better than using Left or Mid functions.

I Use It, Like This =

With CreateObject("Scriptlet.TypeLib")
'' For Del This = {}
 WSH.Echo mid(.Guid ,2, 36)
 WSH.Echo (.Guid)
End With
Schwartser

GUID is a struct and not a string, you need to add a ToString() method to output it as a string.

https://msdn.microsoft.com/fr-fr/library/97af8hh4(v=vs.110).aspx

Response.Write myGuid.ToString("D")
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!