473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

My constants are lost?

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
Jul 19 '05 #1
4 1994
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
--
Will trade ASP help for SQL Server help
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
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

Jul 19 '05 #2
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
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:uq**************@TK2MSFTNGP10.phx.gbl...
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
--
Will trade ASP help for SQL Server help
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
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


Jul 19 '05 #3
Your constants will not lose their values, unless you have them in another
page or something...

Post your code.

Ray at home

--
Will trade ASP help for SQL Server help
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Jul 19 '05 #4

If CLng(Return_Value) = CLng(ucApple) Then

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearning.com
http://www.ielearning.com
714.637.9480 x17
"Neo Chou" <ne*****@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
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

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Ted | last post by:
Is there a way to define a constant value for a color in a CSS declaration? I have numerous colors in different CSS elements, and if I make a change in color, I have to change all the reference...
0
by: David W. Fenton | last post by:
Today I was working on a hideous old app that I created a long time ago that does a lot of showing/hiding/resizing of fields on one of the forms. I had used constants to store reference values for...
4
by: Amadelle | last post by:
Hi all and thanks again in advance, What is the best way of defining global constants in a C# application? (A windows application with no windows forms - basically a set of classes). Would it be...
8
by: Marty | last post by:
Hi, I'm new to C#, I used to code in VB.NET. Where is the best place to declare all my constants and global objects in my C# project to have them accessible globally? I have an event logger...
34
by: newsposter0123 | last post by:
The code block below initialized a r/w variable (usually .bss) to the value of pi. One, of many, problem is any linked compilation unit may change the global variable. Adjusting // rodata const...
6
by: PC | last post by:
Gentlesofts, Forgive me. I'm an abject newbie in your world, using VB 2005 with the dot-Net wonderfulness. So, I'm writing a wonderful class or two to interface with a solemnly ancient...
17
by: Neil Cerutti | last post by:
The Glk API (which I'm implementing in native Python code) defines 120 or so constants that users must use. The constants already have fairly long names, e.g., gestalt_Version, evtype_Timer,...
2
by: Leslie Sanford | last post by:
I want to define a set of floating point constants using templates insteand of macros. I'd like to determine whether these constants are floats or doubles at compile time. In my header file, I have...
54
by: shuisheng | last post by:
Dear All, I am always confused in using constants in multiple files. For global constants, I got some clues from http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx So in header...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.