My constants are lost?

N

Neo Chou

Greetings!

I have a question about constant.

I have a page like:
----------------------------------------------------------------------
<%
Const adInteger = 3 'copied from adovbs.inc
Const ucApple = 0 'user defined constant
Const ucOrange = 1 'user defined constant
%>

<%
Dim Return_Value
' execute a stored procedure and get the return value
' the return value can only be either 0 or 1
%>
<table>
<tr><td>
<%
If Return_Value = ucApple Then
Response.Write "Apple"
ElseIf Return_Value = ucOrange Then
Response.Write "Orange"
Else
Response.Write "Nothing"
End If
%>
</td></tr>
</table>
-----------------------------------------------------------------------
It prints "Nothing" all the time no matter the stored procedure returns 0 or
1. If I replace "ucApple" with 0 and "ucOrange" with 1, the output is
correct. I believe the user defined constants are lost. But I can use
"adInteger" when I call the stored procedure to create parameters. Why? Am
I doing wrong?

Thanks in advance.

Neo
 
R

Ray at

Where's Return_Value coming from (post the code). There isn't any reason
that your values would be lost. Your code below should work fine for values
of 0 and 1 (not 3 though...). I'd suggest using a select case structure for
this, but you can worry about that after you figure out why Return_Value
does not have a value.


Select Case CInt(Return_Value)
Case adInteger : Response.Write "AdInteger value was returned."
Case ucApple : Response.Write "An apple value was returned."
Case ucOrange : Response.Write "An orange value was returned."
Case Else : Response.Write "No worthwhile value was returned."
End Select

Ray at home
 
N

Neo Chou

Thanks for your reply.

In fact, Not the return value is lost, but the constants I assign.

In my case below, ucApple is no longer equal to "0" and ucOrange is no
longer "1" after executing stored procedure. The return value is actually
"0", but 0 (Return_Value) is not equal to "Null" (ucApple), so it doesn't
work. But if I try

Select Case CInt(Return_Value)
Case 0 : Response.Write "An apple value was returned."
Case 1 : Response.Write "An orange value was returned."
Case Else : Response.Write "No worthwhile value was returned."
End Select

It works. I'm confusing...

Neo
 
R

Ray at

Your constants will not lose their values, unless you have them in another
page or something...

Post your code.

Ray at home
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top