..:: MX Studio Fóruns ::..: Conversão de numeros para real. - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Conversão de numeros para real.

#1 User is offline   Edward K 

  • Group: Membros
  • Posts: 91
  • Joined: 23-July 07

  Posted 09 April 2008 - 12:55 PM

Aew galera. tava vagando na internet, e axei uma função interesante
um conversor de numeros para real, se alguem precisar ta ai o código wink.gif
vlws..

CÓDIGO
function Real(num){
  var my_str:String = new String(num);
  var NumMudar:Array = my_str.split(".");
  NumP1 = (NumMudar[0]);
  tan1 = NumMudar.length-1
  if(tan1 > 0 ){
   NumP2 = NumMudar[1];
   if (length(NumP2)== 1){
    NumP2 = ","+NumP2+"0";
   }else{
    NumP2 = ","+substring(NumP2,0,2);
   }
  }else{
   NumP2 = ",00"
  }
  
  var my_str2:String = new String(NumP1);
  var my_array:Array = my_str2.split("");
  tan =  my_array.length-1;
  tx = "";
  u = 0;
  for (var i = tan; i>-1; i--) {
  
   if (u == 3){
    //trace(my_array[i]);  
    tx = (my_array[i]) + "." + tx;
    u = 0;
   }else{
    tx =  (my_array[i])+ tx;
  
   }
  // tx = tx
   u = u + 1
  }
  tx = tx + NumP2;
  return(tx)
}

0

#2 User is offline   ubi_rj 

  • Group: Moderador Global
  • Posts: 2920
  • Joined: 29-June 07

  Posted 09 April 2008 - 01:03 PM

Movido para o local correto.
0

#3 User is offline   Edward K 

  • Group: Membros
  • Posts: 91
  • Joined: 23-July 07

Posted 09 April 2008 - 01:23 PM

opa, foi mal.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)