That does not work. I get an error: Compiler Error Message: BC30451: Name 'XYZ' is not declared.
The problem is that XYZ has not been defined, so checking to see if it is empty causes an error.
I need to test if it has been defined NOT if it is empty.
Paul Jackson
That error message says it has not been declared not that it has not been defined, there is a difference.
You won't be able to test something if it is not declared.
Testing against Nothing tests whether a reference points to an object not whether the reference exists in the first place.
Can I ask what is XZY and in what situation would it not de declared in the code, not sure I understand the scenario where you need to test against something that isn't declared.
To get rid of the compiler error you have you could turn off option strict in web.config but that is generally not considered good practice:
Change the strict option to false in web.config.
You could also turn if off for just that one page by changing the line at the top of the aspx page :
<%@ Page Language="VB" strict="False" %>
skij
ASKER
There is "code behind" code that declares XYZ if certain conditions are met. The "code behind" code is compiled and I don't have access to it. I need to test if that code has already been declared or not. If there is no other way, could "try" and "catch" be used?
Open in new window