# Arithmetic

Discussion in 'ASP General' started by Raz, Aug 9, 2007.

1. ### RazGuest

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

Thanks!

Raz, Aug 9, 2007

2. ### Bob Barrows [MVP]Guest

Raz wrote:
> 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
>

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.

Bob Barrows [MVP], Aug 9, 2007

3. ### RazGuest

Thanks! It's working now.

"Bob Barrows [MVP]" <> wrote in message
news:...
> Raz wrote:
>> 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
>>

> 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.
>
>

Raz, Aug 9, 2007
4. ### Evertjan.Guest

Bob Barrows [MVP] wrote on 09 aug 2007 in
microsoft.public.inetserver.asp.general:

>> if bdiq=4 then bdiqscore=bdiq-2 end if
>> %>
>>
>> When I do response.write(bdiqscore), I get the answer of 2, but with
>>

> 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

--
Evertjan.
The Netherlands.