-
array issue
Thanks in advance for your help!!!
My issue is checking a array variable in a if statement to see if it empty.
Like
if pram(2) = "" then
if empty redirect
else
not empty run code
end if
This is how my array is created
strString=Request.ServerVariables("HTTP_X_ORIGINAL _URL")
strArray = split(strString, "/")
Redim pram(uBound(strArray))
For i = 0 to uBound(strArray)
pram(i) = strArray(i)
Next
I can get empty array by
if uBound(strArray) = -1 then
But I want to check the second item in the array if it's empty. The first item in the array will exist but the second item may not exist and then I need the to redirect the user accordingly.
-
be careful of using the If strMyArray(1) = "" condition to determine if your array is empty.
first, this is actually checking the second element in the array. remember that arrays are zero-based! so if you really wanted to do this, it would have to be written as If strMyArray(0) = ""
and the second reason to be careful using this, is that an empty string in one element doesn't necessarily mean that all other elements are empty too!
Sorry! Noticed this is an old thread!