Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: number format commas insert numbers integer
#DefineFunction AddCommas(passednumstring) fractpart=ItemExtract(2,passednumstring,".") intpart=ItemExtract(1,passednumstring, ".") groups= ((strlen(intpart)-1) / 3 ) +1 answer="" for y=1 to groups if y==1 ptr=( (strlen(intpart)-1) mod 3) +1 answer=strsub(intpart,1, ptr ) ptr=ptr +1 else answer=strcat(answer, ",", strsub(intpart, ptr , 3)) ptr=ptr+3 endif next if fractpart!="" answer=strcat(answer,".",fractpart) endif return (answer) #endfunction ;Example Usage while 1 xxx=Askline("AddCommas","Enter test number",1234567.89) Pause(xxx,AddCommas(xxx)) endwhile exit
Example UDF #2
;-------------------------------------- ; Add commas to a number ;-------------------------------------- #DefineFunction Commas(N) M = "" S = "" if StrSub(N,1,1) == "-" M = "-" N = StrSub(N,2,-1) endif while (StrLen(N) > 3) S = StrCat(",",StrFixLeft(N,"0",3),S) N = StrSub(N,1,StrLen(N)-3) endwhile return StrCat(M,N,S) #EndFunction
Article ID: W14744
Filename: Add commas to numbers.txt
File Created: 2005:03:28:14:44:48
Last Updated: 2005:03:28:14:44:48