You can't check against two different Types like that. If the variable is an Integer (which it is in this case), checking which String it is will simply fail with a Type mismatch error. You can check first whether it is an Integer or a String, then check the value after that of only that Type. Better yet, whatever is feeding bAsListScreen into the function, have it always feed a String (or always an Integer), by doing conversion if necessary.