12/31/2023 0 Comments Vba excel convert to numberIf Val(Left(TensText, 1)) = 1 Then ' If value between 10-19. If Mid(MyNumber, 1, 1) "0" Then Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred " End If ' Convert the tens and ones place. If DecimalPlace > 0 Then Paisa = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _ "00", 2)) MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) End If Count = 1 Do While MyNumber "" Temp = GetHundreds(Right(MyNumber, 3)) If Temp "" Then Rupees = Temp & Place(Count) & Rupees If Len(MyNumber) > 3 Then MyNumber = Left(MyNumber, Len(MyNumber) - 3) Else MyNumber = "" End If Count = Count + 1 Loop If M圜urrencyPlace = "P" Then Select Case Rupees Case "" Rupees = M圜urrency & "s" & " Zero" Case "One" Rupees = M圜urrency & " One" Case Else Rupees = M圜urrency & "s " & Rupees End Select Else Select Case Rupees Case "" Rupees = "Zero " & M圜urrency & "s" Case "One" Rupees = "One " & M圜urrency Case Else Rupees = Rupees & " " & M圜urrency & "s" End Select End If If M圜urrencyDecimalsPlace = "S" Then Select Case Paisa Case "" Paisa = " Only" Case "One" Paisa = " and One " & M圜urrencyDecimals & " Only" Case Else Paisa = " and " & Paisa & " " & M圜urrencyDecimals & "s Only" End Select Else Select Case Paisa Case "" Paisa = " Only" Case "One" Paisa = " and " & M圜urrencyDecimals & " One " & " Only" Case Else Paisa = " and " & M圜urrencyDecimals & "s " & Paisa & " Only" End Select End If SpellCurr = Rupees & Paisa End Function '******************************************* ' Converts a number from 100-999 into text * '******************************************* Function GetHundreds( ByVal MyNumber) Dim Result As String If Val(MyNumber) = 0 Then Exit Function MyNumber = Right( "000" & MyNumber, 3) ' Convert the hundreds place. DecimalPlace = InStr(MyNumber, ".") ' Convert Paisa and set MyNumber to Rupee amount. MyNumber = Trim(Str(MyNumber)) 'Position of decimal place 0 if none. Function SpellCurr( ByVal MyNumber, _ Optional M圜urrency As String = "Rupee", _ Optional M圜urrencyPlace As String = "P", _ Optional M圜urrencyDecimals As String = "Paisa", _ Optional M圜urrencyDecimalsPlace As String = "S") '***************************************************' Dim Rupees, Paisa, Temp Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " 'String representation of amount.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |