Saturday, January 19, 2013

How to verify the existance of an environmental variable

The below code illustrate the existence of an environmental variables:

function checkEnvironmentalVariableExists(sEnvVarName)
    Err.clear
    On error resume next
    envValue=Environment.Value(sEnvVarName) 'Env exist
    If Err.number<>0 Then
        checkEnvironmentalVariableExists=False
    else
        checkEnvironmentalVariableExists=true
    End If
    On error goto 0
end function

Environment.Value("name")="Uday"
retVal=checkEnvironmentalVariableExists("name123")
If retVal=true Then
    print "Environmental Variable exists"
else
    print "Environmenta Variable does not exist"
End If

No comments: