Turn lowercase amounts into uppercase amounts under VBScript

Source: Internet
Author: User
Tags end lowercase
Vbscript| Capital | amount | lowercase

'--------------------a set of functions that convert numbers to Chinese characters------------------------
' Author: northsnow
' Date: 20061007
' Call Method: A=convertnumtostr (' 1234.5678 ')
' function: Convert such a string 1234.5678 into one thousand Woocher points

"Converts a string of numbers to a corresponding Chinese character.
function Convertnumtostr () function convertnumtostr (pnum)
Dim onum,rvalue
Onum=pnum:rvalue= ""

' If the given is not a reasonable number, then return the empty string
Const z_patnum= "^d+ (. { 1}d+)? $ "
Set R=new regexp
If not r.test (Onum) Then
Exit function
End If

' Remove the useless 0 in front of the number
Set Rljc=new REGEXP
Rljc.pattern= "^0{2,} ([^.])"
Onum=rljc.replace (Onum, "$")
Rljc.pattern= "^0{2,} (.)"
Onum=rljc.replace (Onum, "0$1")

' Separate the decimal points before and after
Arrnum=split (Onum, ".")
Frontnum=arrnum (0)
Backnum= ""
If UBound (arrnum) >0 then Backnum=arrnum (1)

'----Convert the number before the decimal point----
Olen=len (Frontnum)

If Olen=1 then ' only one
ElseIf olen=2 Then ' only two-bit
if (Mid (frontnum,1,1)) <> "1" Then Rvalue=convertnumtocc (Mid (frontnum,1,1))
Rvalue=rvalue & Getdigit (2)
if (Mid (frontnum,2,1)) <> "0" then Rvalue=rvalue & Convertnumtocc (Mid (frontnum,2,1))
Else ' greater than two-bit situation
Dim Curpos,curnum,haszero
Haszero=false ' indicates that there was no connection between the 0
For I=1 to OLen
Curpos=olen-i + 1
Curnum=mid (frontnum,i,1)
If CInt (curnum) =0 Then ' the current number of digits is zero
' When the current bit is million bits or billions of bits, it is processed
if (curPos-1) mod 4=0 and Curpos>4 Then
Rvalue=rvalue & Getdigit (CurPos)
End If
Else ' Current number is not 0
If Haszero Then
Rvalue=rvalue & "0"
End If
Rvalue=rvalue & Convertnumtocc (curnum) & Getdigit (CurPos)
End If
End If
Rvalue=rvalue & "Yuan"
' Convert the following decimal point
If backnum<> "" Then
Strback= ""
If Len (backnum) >2 Then
Backnum=left (backnum,2)
End If
For I=1 to Len (backnum)
Strback=strback & Convertnumtocc (Mid (backnum,i,1)) & GetDigit2 (i)
Rvalue=rvalue & Strback
Rvalue=rvalue & "Whole"
End If
End Function

"Converts a number to the corresponding Chinese character
function Convertnumtocc () function Convertnumtocc (pnum)
Select Case Pnum
Case 1:convertnumtocc= "one"
Case 2:convertnumtocc= "II"
Case 3:convertnumtocc= "three"
Case 4:convertnumtocc= "Restaurant"
Case 5:convertnumtocc= "WU"
Case 6:convertnumtocc= "Lu"
Case 7:convertnumtocc= "Qi"
Case 8:convertnumtocc= "BA"
Case 9:convertnumtocc= "JIU"
Case 0:convertnumtocc= "0"
End Select
End Function

' Returns the corresponding Chinese characters according to the number of digits
function Getdigit () function getdigit (odigit)
If Odigit=1 Then

ElseIf (odigit+2) mod 4=0 Then
getdigit= "Pick Up"
ElseIf (odigit + 1) mod 4=0 Then
getdigit= "Bai"
ElseIf odigit MoD 4=0 Then
getdigit= "Qian"
ElseIf (oDigit-1) mod 4=0 Then
if ((oDigit-1)/4) mod 2=0 Then
Getdigit= "billion"
Getdigit= "Million"
End If
End If
End Function

function GetDigit2 () function getDigit2 (odigit)
If Odigit=1 Then
Getdigit2= "Corner"
ElseIf odigit=2 Then
getdigit2= "Min"
End If
End Function

Aaa= "108765.54"
Response. Write AAA
Response. Write Convertnumtostr (AAA)


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.