Results 1 to 6 of 6

Thread: Multiple If statements

  1. #1

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Resolved Multiple If statements

    Hey everyone I need a little help again I am rewriting my calculator program and am having problems with my code...

    VB Code:
    1. function disp_prompt()
    2. {
    3. var i= document.getElementById("investment").value;
    4. var r= document.getElementById("reinvest").value;
    5. r=r - 0;
    6. i=i - 0;
    7. c=0+1
    8. s=0
    9. s1=100
    10. s2=1000
    11. s3=10000
    12. q=100
    13. q2=200
    14. q3=300
    15. total=0
    16.  
    17. if (i>s && i<s1);
    18. if (c=1)<----- I cant get JS to recognize this code it just passes over it... or just doesnt do anything
    19. {
    20. total=i + i * q / 100
    21. for (i=2;i<=r;i++)
    22. total=total + total * q / 100
    23.  
    24. document.getElementById("profit").value= "$" +total 'but if i add a "+ c" it will add the number...
    25.  
    26. }
    27. else
    28. {
    29. total=1000009
    30.  
    31. document.getElementById("profit").value= "$" +total
    32. }
    33. }


    What am I doing wrong????
    Last edited by messup000; Jan 12th, 2006 at 12:26 AM.

  2. #2
    Addicted Member bulletrick's Avatar
    Join Date
    Jul 2005
    Location
    Philippines
    Posts
    248

    Cool Re: Multiple If statements

    Code:
    if (i>s && i<s1);
    What does this mean? Try using the Watch Window. It's very helpful.

  3. #3

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Multiple If statements

    if i>0 and if i<100

    watch window? you mean like the vbcode window

  4. #4

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Multiple If statements

    well i ended up using c<0 or c>0 instead... it seemed to work so thx for the help anyway...

  5. #5
    Member
    Join Date
    Dec 2006
    Location
    Malaysia
    Posts
    53

    Re: Multiple If statements

    if (i>s && i<s1);

    Do not contain ";" behind if statement
    Missing "{", so code is terminated!

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Multiple If statements

    Quote Originally Posted by messup000
    Hey everyone I need a little help again I am rewriting my calculator program and am having problems with my code...

    VB Code:
    1. function disp_prompt()
    2. {
    3. var i= document.getElementById("investment").value;
    4. var r= document.getElementById("reinvest").value;
    5. r=r - 0;
    6. i=i - 0;
    7. c=0+1
    8. s=0
    9. s1=100
    10. s2=1000
    11. s3=10000
    12. q=100
    13. q2=200
    14. q3=300
    15. total=0
    16.  
    17. if (i>s && i<s1);
    18. if (c=1)<----- I cant get JS to recognize this code it just passes over it... or just doesnt do anything
    19. {
    20. total=i + i * q / 100
    21. for (i=2;i<=r;i++)
    22. total=total + total * q / 100
    23.  
    24. document.getElementById("profit").value= "$" +total 'but if i add a "+ c" it will add the number...
    25.  
    26. }
    27. else
    28. {
    29. total=1000009
    30.  
    31. document.getElementById("profit").value= "$" +total
    32. }
    33. }


    What am I doing wrong????
    c=1 <-- will assign the value of 1 to c and take the left most side of the expression after assignment as the vlaue (1). Hence it will always evaluate to true.

    Instead of using the assignment operator =, you should use the equality operator ==

    if (c == 1)
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width