如何检查Environment Variable是否存在 Public Function IsEnvExist(ByVal varName) IsEnvExist = True On Error Resume Next Dim envVal envVal = Environment(varName) If err.number<>0 Then IsEnvExist = False End If On Error Goto 0 End Function msgBox IsEnvExist("Invalid") 有关Environment Variable被赋值 If we try to use Set to assign an object to the Environment Variable, 'Type mismatch' exception is raised. 1. use a string definition of the object and then convert it to an object 2. assign the object to the variable without using the Set Method 1 Environment("BrowserObj") = "Browser(""creationtime:=0"")" Dim objBrowser Excute "set objBrowser = "& Environment("BrowserObj") objBrowser.close Method2 Environment("BrowserObj") = Browser("creationtime:=0") Dim objBrowser
set objBrowser = Environment("BrowserObj")
objBrowser.close
How an array is passed using Environment Variable QTP throws a "this array is fixed or temporarily locked" exception, if we try to pass a fixed length array using Environment Variable. Dim fixedArr(3) For i = LBound(fixedArr,1) to UBound(fixedArr,1) fixedArr(i) = Cstr(i) Next Dim dynArr dynArr = fixedArr Environment.Value("passArray") = dynArr |
|
来自: 恋家的孩子 > 《vbscript》