Arithmetic

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

  1. Raz

    Raz Guest

    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!
    Raz, Aug 9, 2007
    #1
    1. Advertising

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

    --
    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
    #2
    1. Advertising

  3. Raz

    Raz Guest

    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
    >> 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
    >
    > --
    > 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
    #3
  4. Raz

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


    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.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 9, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jonathan Bromley
    Replies:
    1
    Views:
    3,856
    Jim Lewis
    Aug 15, 2003
  2. ALuPin

    Arithmetic Libraries

    ALuPin, Feb 10, 2004, in forum: VHDL
    Replies:
    1
    Views:
    535
    Ralf Hildebrandt
    Feb 10, 2004
  3. George Durzi

    Performing Arithmetic on DataTable Columns

    George Durzi, Jun 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,012
    Alvin Bruney [MVP]
    Jun 7, 2004
  4. Steven Davies

    Java Arithmetic - Using MOD (%)

    Steven Davies, Feb 1, 2005, in forum: Java
    Replies:
    3
    Views:
    91,029
    Steven Davies
    Feb 1, 2005
  5. joshc
    Replies:
    5
    Views:
    537
    Keith Thompson
    Mar 31, 2005
Loading...

Share This Page