PowerBuilder Translate/Convert Money To String Vietnamese
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | global type f_translate_to_vietnamese from function_object end type forward prototypes global function string f_translate_to_vietnamese (string as_money) end prototypes global function string f_translate_to_vietnamese (string as_money);// Function: f_translate_to_vietnamese // Input : number string // Output : character string // Using : translate number string to character string String result, readchar, numberchar, threenumber, threechar String numberone, numbertwo, numberthree, translate Integer i, j, s, li_find li_find = Pos(as_money, ",", 1) Do While li_find <> 0 as_money = Left(as_money, li_find - 1) + Right(as_money, Len(as_money) - li_find) li_find = Pos(as_money, ",", li_find + 1) Loop If Not Match(as_money, "^[0-9]+$") Then MessageBox("Notice", "You enter a value invalid") Return "" End If If Len(as_money) > 15 Then MessageBox("Notice", "Money is so large") Return "" End If If Long(as_money) = 0 Then result = 'KHONG DONG' Return result End If as_money = Fill(" ", 15 - Len(as_money)) + as_money readchar = ' TRAM MUOI NGAN TRAM MUOI TY TRAM MUOI TRIEU TRAM MUOI NGAN TRAM MUOI DONG' numberchar = 'MOT HAI BA BON NAM SAU BAY TAM CHIN' For i = 1 To 5 threenumber = Mid(as_money, i*3 - 2, 3) If threenumber <> ' ' Then numberone = Left(threenumber, 1) numbertwo = Mid(threenumber, 2, 1) numberthree = Right(threenumber, 1) threechar = '' For j = 1 To 3 translate = '' s = Double(Mid(threenumber, j, 1)) If s > 0 Then translate = Trim(Mid(numberchar, s*4 - 3, 4))+' '+Trim(Mid(readchar,(i - 1)*15+j*5 - 4,5))+' ' End If Choose Case j Case 1 If s = 0 And numberone <> ' ' And threenumber <> '000' Then translate = "KHONG " + Trim(Mid(readchar, (i - 1)*15+j*5 - 4,5))+' ' End If Case 2 If s = 1 Then translate = 'MUOI ' End If If s = 0 And numberthree <> '0' Then If (Pos('123456789', numberone) > 0) Or (numberone = '0' And i = 5) Then translate = 'LE ' End If End If Case 3 If s = 0 And threenumber <> '000' Then translate = Trim(Mid(readchar, (i - 1)*15+j*5 - 4,5))+' ' End If If i = 5 And threenumber = '000' Then translate = 'DONG' End If If i = 2 And threenumber = '000' Then translate = 'TY ' End If If s = 5 And numbertwo <> '0' Then translate = "LAM" + Mid(translate, 4) End If End Choose threechar = threechar + translate Next result = result + threechar End If Next Return result end function |
Find Projects On Github click here
Good Luck!