FUNCTION ChangeMoneyStr(strValue)
DIM strReturn, nShare, nRest, nCount, strDecimal
' 소숫점 있으면
IF InStr(strValue, ".") > 0 THEN
strDecimal = Mid(strValue, InStr(strValue, "."))
strValue = Left(strValue, InStr(strValue, ".") - 1)
ELSE
strDecimal = ""
END IF
IF Len(strValue) > 3 THEN
nShare = Len(strValue) / 3
nRest = Len(strValue) MOD 3
IF nRest = 0 THEN
nRest = 3
nShare = nShare - 1
END IF
strReturn = Left(strValue, nRest)
FOR nCount = 0 TO nShare - 1
IF nCount < nShare THEN strReturn = strReturn & ","
strReturn = strReturn & Mid(strValue, CInt(nRest) + 1 + (nCount * 3), 3)
NEXT
ChangeMoneyStr = strReturn & strDecimal
ELSE
ChangeMoneyStr = strValue & strDecimal
END IF
END FUNCTION
예>
DIM strMoney
strMoney = ChangeMoneyStr( "123000" )
response.write(strMoney)
123,000
DIM strReturn, nShare, nRest, nCount, strDecimal
' 소숫점 있으면
IF InStr(strValue, ".") > 0 THEN
strDecimal = Mid(strValue, InStr(strValue, "."))
strValue = Left(strValue, InStr(strValue, ".") - 1)
ELSE
strDecimal = ""
END IF
IF Len(strValue) > 3 THEN
nShare = Len(strValue) / 3
nRest = Len(strValue) MOD 3
IF nRest = 0 THEN
nRest = 3
nShare = nShare - 1
END IF
strReturn = Left(strValue, nRest)
FOR nCount = 0 TO nShare - 1
IF nCount < nShare THEN strReturn = strReturn & ","
strReturn = strReturn & Mid(strValue, CInt(nRest) + 1 + (nCount * 3), 3)
NEXT
ChangeMoneyStr = strReturn & strDecimal
ELSE
ChangeMoneyStr = strValue & strDecimal
END IF
END FUNCTION
예>
DIM strMoney
strMoney = ChangeMoneyStr( "123000" )
response.write(strMoney)
123,000
반응형