tailieunhanh - Tự học Excel part 22
' Strip off cents from remainder to convert. MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) End If Count = 1 Do While MyNumber "" ' Convert last 3 digits of MyNumber to English dollars. Temp = ConvertHundreds(Right(MyNumber, 3)) If Temp "" Then Dollars = Temp & Place(Count) & Dollars If Len(MyNumber) 3 Then ' Remove last 3 converted digits from MyNumber. MyNumber = Left(MyNumber, Len(MyNumber) - 3) Else MyNumber = "" End If Count = Count + 1 Loop ' Clean up dollars. Select Case Dollars Case "" Dollars = "khong Nghin" Case "One" Dollars = "Mot Nghin". | Strip off cents from remainder to convert. MyNumber Trim Left MyNumber DecimalPlace - 1 End If Count 1 Do While MyNumber Convert last 3 digits of MyNumber to English dollars. Temp ConvertHundreds Right MyNumber 3 If Temp Then Dollars Temp Place Count Dollars If Len MyNumber 3 Then Remove last 3 converted digits from MyNumber. MyNumber Left MyNumber Len MyNumber - 3 Else MyNumber End If Count Count 1 Loop Clean up dollars. Select Case Dollars Case Dollars khong Nghin Case One Dollars Mot Nghin Case Else Dollars Dollars Nghin End Select Clean up cents. Select Case Cents Case Cents va khong Dong Case One Cents va mot Dong Case Else Cents va Cents Dong End Select ConvertCurrencyToVietnamese Dollars Cents End Function Private Function ConvertHundreds ByVal MyNumber Dim Result As String Exit if there is nothing to convert. If Val MyNumber 0 Then Exit Function Append leading zeros to number. MyNumber Right 000 MyNumber 3 Do we have a hundreds place digit to convert If Left MyNumber 1 0 Then Result ConvertDigit Left MyNumber 1 Tram End If Do we have a tens place digit to convert If Mid MyNumber 2 1 0 Then Result Result ConvertTens Mid MyNumber 2 Else If not then convert the ones place digit. Result Result ConvertDigit Mid MyNumber 3 End If ConvertHundreds Trim Result End Function Private Function ConvertTens ByVal MyTens Dim Result As String Is value between 10 and 19 If Val Left MyTens 1 1 Then Select Case Val MyTens Case 10 Result Muoi Case 11 Result Muoi mot Case 12 Result Muoi hai Case 13 Result Muoi ba Case 14 Result Muoi bon Case 15 Result Muoi lam Case 16 Result Moi sau Case 17 Result Muoi bay Case 18 Result Muoi tam Case 19 Result Muoi chin Case Else End Select Else . otherwise it s between 20 and 99. Select Case Val Left MyTens 1
đang nạp các trang xem trước