본문 바로가기
프로그램ing/ASP

[ASP] 천원단위로 콤마(,) 찍기

by 철밥통 2019. 3. 29.
반응형

ASP 언어로 [ASP]  천원단위로 콤마(,) 찍기

FormatNumber 

 

 - FormatNumber 란?

    FormatNumber 는 숫자의 표시형태(소수점 포함)를 선택하는 함수입니다.


 - ASP FormatNumber 사용방법

FormatNumber("[값 또는 변수]", 
              [표시 소수점 자리, 0-무한대?], 
              [0 표시설정, true / false], 
              [음수부호 표시설정, true / false], 
              [천단위 콤마 설정, true / false])

- 사용 예제

Dim dr_amt, cr_amt

dr_amt = 10
cr_amt = "text"

if isnull(dr_amt) then
 dr_amt = ""
elseif isnumeric(dr_amt) then
 dr_amt = FormatNumber(dr_amt, 0, false, true, true)
end if

if isnull(cr_amt) then
 cr_amt = ""
elseif isnumeric(cr_amt) then
 cr_amt = FormatNumber(cr_amt, 0, false, true, true)
end if

response.write dr_amt & " / " & cr_amt 
response.end

* FormatNumber에 문자나 NULL값이 들어가게 되면'800a000d' 에러가 납니다.

  따라서 숫자 형식임을 확인하는 코드를 상단에 넣어주면 안정적으로 사용할 수 있습니다.

 

 

 

 

반응형

댓글