Arithmetic

R

Raz

Hi,

I have seven radio buttons that a user might check and the values of the
buttons are 0, 1, 2, 3, 4, 5, and 6 for a response. The same variable name
is used for each radio button option (bdiq). Let's say that the user might
select radio button with the value of 4. Is there a way to "change" the
value from a 4 to a 2? This is what I have:

<%
Dim bdiq
Dim bdiqscore
Dim totalscore
totalscore = bdiqscore

if bdiq=4 then bdiqscore=bdiq-2 end if
%>

When I do response.write(bdiqscore), I get the answer of 2, but with
totalscore the answer is 4 from the radio button selected.

Thanks!
 
B

Bob Barrows [MVP]

Raz said:
Hi,

I have seven radio buttons that a user might check and the values of
the buttons are 0, 1, 2, 3, 4, 5, and 6 for a response. The same
variable name is used for each radio button option (bdiq). Let's say
that the user might select radio button with the value of 4. Is
there a way to "change" the value from a 4 to a 2? This is what I
have:

<%
Dim bdiq
Dim bdiqscore
Dim totalscore
totalscore = bdiqscore

if bdiq=4 then bdiqscore=bdiq-2 end if
%>

When I do response.write(bdiqscore), I get the answer of 2, but with
totalscore the answer is 4 from the radio button selected.
You seem to be thinking that "totalscore = bdiqscore" is a formula. It's
not. It is a value-assignment. it says: assign the value CURRENTLY held
by the bdiqscore variable to the totalscore variable. If bdiqscore
subsequently changes, totalscore will not change on its own! You have to
repeat the value-assignment
 
R

Raz

Thanks! It's working now.

Bob Barrows said:
You seem to be thinking that "totalscore = bdiqscore" is a formula. It's
not. It is a value-assignment. it says: assign the value CURRENTLY held
by the bdiqscore variable to the totalscore variable. If bdiqscore
subsequently changes, totalscore will not change on its own! You have to
repeat the value-assignment

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
 
E

Evertjan.

Bob Barrows [MVP] wrote on 09 aug 2007 in
microsoft.public.inetserver.asp.general:
You seem to be thinking that "totalscore = bdiqscore" is a formula. It's
not. It is a value-assignment. it says: assign the value CURRENTLY held
by the bdiqscore variable to the totalscore variable. If bdiqscore
subsequently changes, totalscore will not change on its own! You have to
repeat the value-assignment

And

if bdiq=4 then bdiqscore=bdiq-2 end if

is an inline if-then, that should not have an "end if".
[That it works is a well documented vbs error
MS does not dare to correct.]

Use:

if bdiq = 4 then bdiqscore = bdiq - 2
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top