dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: string to number conversion?

  1. #1
    Senior Member maksum's Avatar
    Join Date
    Oct 2002
    Location
    Portland, OR
    Posts
    118

    string to number conversion?

    Ok, here's my issue. How can I get a string to become a number? It seems like it should be simple, but I just can't find it. I can figure out how to manually convert a number to a string, but not a string to a number.

    Here's my little sample code:

    code:

    var varone = "2345";
    var vartwo = "600";
    //POINT X
    if(varone < vartwo){
    //this will be a completely false statement
    trace(varone + " is less than " + vartwo);
    }



    So what can I do at "POINT X" so that they actually become numbers and that message doesn't come up?

    Thanks in advance!

    Mike

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    On the fifth floor.
    Posts
    1,202
    code:
    var varone = "2345";
    var vartwo = "600";
    //POINT X
    if(Number(varone) < Number(vartwo)){
    //this will be a completely false statement
    trace(varone + " is less than " + vartwo);
    }else if (Number(varone) == Number(vartwo)){
    trace(varone + " is equal " + vartwo);
    }else{trace(varone + " is bigger then " + vartwo)
    }



  3. #3
    Senior Member maksum's Avatar
    Join Date
    Oct 2002
    Location
    Portland, OR
    Posts
    118
    That works!

    Thanks a ton.

    Mike

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

HTML5 Development Center