ASP for case-insensitive amount conversion

Source: Internet
Author: User

ASP for case-insensitive amount conversion
<! -- # Include file = Common. asp -->
<%
Dim tmpnum
'Lower-case amount passed from the first page
Tmpnum = request ("page1num ")
'Call and display the upper-case amount
Response. Write RMB (cdbl (tmpnum ))
Response. End
%>

Common. asp
<%
Function RMB (Num)

Num = formatnumber (Num, 2)
Dim numlist
Dim rmblist
Dim numlen
Dim numchar
Dim numstr
Dim N
Dim N1, N2
Dim Hz
Numlist = "Zero errors"
Rmblist = "yuanqibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaibaiwan"

If num> 9999999999999.99 then
RMB = "RMB out of range"
Exit Function
End if

Numstr = CSTR (num* 100)
Numlen = Len (numstr)
N = 1
Do while n <= numlen
Numchar = CINT (mid (numstr, N, 1 ))
N1 = mid (numlist, numchar + 1, 1)
N2 = mid (rmblist, numlen-n + 1, 1)
If not n1 = "zero" then
Hz = Hz + CSTR (N1) + CSTR (N2)
Else
If n2 = "" or N2 = "" or N2 = "Yuan" or n1 = "zero" then
Do While right (Hz, 1) = "0"
Hz = left (Hz, Len (HZ)-1)
Loop
End if
If (n2 = "" or (n2 = "" and Right (Hz, 1) <> "") or N2 = "") then
Hz = Hz + CSTR (N2)
Else
If left (right (Hz, 2), 1) = "zero" or right (Hz, 1) <> "" then
Hz = Hz + N1
End if
End if
End if
N = n + 1
Loop
Do While right (Hz, 1) = "0"
Hz = left (Hz, Len (HZ)-1)
Loop
If right (Hz, 1) = "Yuan" then
Hz = Hz + "whole"
End if
RMB = Hz
End Function

%>

This version solves the problem that decimal points cannot be reached. The processing method conforms to the accounting method!

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.