Hi Steve,
First of all, that's not a global variable. It's a Private field of your
inherited Page Class (remember, this is object-oriented programming, not
procedural ASP). Secondly, it is not anything until you assign a value to it
(it is null, or Nothing in VB.Net). A field or variable declaration is
simply a declaration that a certain amount of memory space (the size of the
data type) should be allocated for storing that type of data. It has no
value until one is assigned to it.
Your error indicates that an object reference has been used that is null.
There are only 2 objects in the statement; both are strings. Apparently, you
are not assigning a value to at least one of them prior to invoking the Sub
that is comparing them.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:Oh**************@TK2MSFTNGP11.phx.gbl...
Okay I found the problem. Apparently I'm having troubles with how to use
global variables.
<script language="VBScript" runat="server>
dim strAnswer as String
sub getInfo()
strAnswer = <the code to get the answer>
end sub
sub validateAnswer()
if(strAnswer.toUpper() = strUserAnswer.toUpper())
etc . . . . .
end sub
</script>
Should the strAnswer from getInfo() be the same strAnswer in
validateAnswer()?
--
Steve Evans
Email Services
SDSU Foundation
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl... The only possible thing that could be wrong in this case is that one of
the variable values is null. Those are the only 2 object references in the
statement.
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"- Steve -" <se****@foundation.sdsu.edu> wrote in message
news:eT**************@TK2MSFTNGP09.phx.gbl... The following line of vb.net code works fine:
if(strAnswer.toUpper() = strUserAnswer.toUpper())
However in an ASP.net page I'm told
Object reference not set to an instance of an object
What am I doing wrong?
--
Steve Evans
Email Services
SDSU Foundation