Excel does not recognise the figure of Zero at the unit place with Tens

Status
Not open for further replies.

NimishK

Well-known Member
Joined
Sep 4, 2015
Messages
688
I've worked for converting figures to words in the following manner and differently only after decimal
from the link with my previous thread 1031511-converting-figures-words-seems-correction-required

I get following results

When entered 0.25 the Mid$(Paisa$,1,2) of Text = 25

LeftDigit$ = Mid$(Paisa$, 1, 1) = Result = 2
RightDigit$ = Mid$(Paisa$, 2, 1) = Result = 5
converts to word Paise TwentyFive Converts Correctly

When entered 0.15 the Mid$(Paisa$,1,2) of Text = 15
LeftDigit$ =Mid$(Paisa$,1,1) of Text = 0.15 =1
RightDigit$ =Mid$(Paisa$,2,1) of Text = 0.15 = 5
converts to word Paise Fifteen Converts Correctly

When entered 0.05 the Mid$(Paisa$,1,2) of Text = 5
LeftDigit$ =Mid$(Paisa$,1,1) of Paisa$ = .05 = 0
RightDigit$ =Mid$(Paisa$,2,1) of Paisa$ = .05 = 5
converts to word Paise Five Converts Correctly

But corrections require here
When entered 0.50 or 0.5 the Mid$(Paisa$,1,2) of Text displays as .5
LeftDigit$ =Mid$(Paisa$,1,1) of Paisa$ = 0.50 = . Decimal is seen
RightDigit$ =Mid$(Paisa$,2,1) of Paisa$ = 0.50 = 5
converts to word Paise Only Converts Wrongly


code in Module1
Code:
Public Amount, Digits As String, Paisa As String, paise As String, Amounted As String

Function FigtoWords(ByVal Amount)

Dim Tens$(9)
Dim Ones$(19)
Tens$(1) = "Ten"
Tens$(2) = "Twenty"
Tens$(3) = "Thirty"
Tens$(4) = "Forty"
Tens$(5) = "Fifty"
Tens$(6) = "Sixty"
Tens$(7) = "Seventy"
Tens$(8) = "Eighty"
Tens$(9) = "Ninety"


Ones$(1) = "One":  Ones$(2) = "Two": Ones$(3) = "Three": Ones$(4) = "Four"
Ones$(5) = "Five": Ones$(6) = "Six":  Ones$(7) = " Seven": Ones$(8) = "Eight"
Ones$(9) = "Nine": Ones$(10) = "Ten": Ones$(11) = "Eleven": Ones$(12) = "Twelve"
Ones$(13) = "Thirteen": Ones$(14) = "Fourteen": Ones$(15) = "Fifteen": Ones$(16) = "Sixteen"
Ones$(17) = "Seventeen": Ones$(18) = "Eighteen": Ones$(19) = " Nineteen"

Rupees$ = Left$(Amounted$, 11)
Words$ = "Paise "


If Val(Amounted$) = 0 Then Words$ = ""
If Val(Amounted$) = 1 Then Words$ = "Paisa "
If Val(Amounted$) < 2 Then Words$ = "Paisa "


Rupia$ = Left$(Rupees$, 2)
Amounted$ = Format(UserForm1.TextBox1.Text, "#.##")
paise$ = Right$(Amounted$, 2)

Paisa$ = Left$(paise$, 3)
If Val(Paisa$) = 0 Then
   Words$ = Words$ + " Only. "
Else
 If Val(Paisa$) > 0 Then
  GoSub ParsePaise
  Words$ = Words$ + ""
 End If
 End If


ParsePaise:
Digits$ = Mid$(Paisa, 1, 2)
If Val(Digits$) > 0 And Val(Digits$) <= 19 Then
Words$ = Words$ + " And Paise " + Ones$(Val(Digits$)) + " Only."
End If
Digits$ = Mid$(Paisa, 1, 2)
If Val(Digits$) >= 20 Then
    LeftDigit$ = Mid$(Paisa$, 1, 1)
    RightDigit$ = Mid$(Paisa$, 2, 1)
    
Words$ = Words$ + " " + Tens$(Val(LeftDigit$))


If Val(RightDigit$) > 0 Then
   Words$ = Words$ + "-" + Ones$(Val(RightDigit$)) + " Only."
  End If

End If

FigtoWords = Words$

     Exit Function
End Function

Public Sub Numbertowords(n%, Word As String)
Select Case n%
Case Is = 1: Word = "One": Case Is = 2: Word = "Two"
Case Is = 3: Word = "Three": Case Is = 4: Word = "Four"
Case Is = 5: Word = "Five": Case Is = 6: Word = "Six"
Case Is = 7: Word = "Seven": Case Is = 8: Word = "Eight"
Case Is = 9: Word = "Nine": Case Is = 10: Word = "Ten"
Case Is = 11: Word = "Eleven": Case Is = 12: Word = "Twelve"
Case Is = 13: Word = "Thirteen": Case Is = 14: Word = "Fourteen"
Case Is = 15: Word = "Fifteen": Case Is = 16: Word = "Sixteen"
Case Is = 17: Word = "Seventeen": Case Is = 18: Word = "Eighteen"
Case Is = 19: Word = "Nineteen": Case Is = 20: Word = "Twenty"
Case Is = 21: Word = "Twenty-One"
Case Is = 22: Word = "Twenty-Two"
Case Is = 23: Word = "Twenty-Three"
Case Is = 24: Word = "Twenty-Four"
Case Is = 25: Word = "Twenty-Five"
Case Is = 26: Word = "Twenty-Six"
Case Is = 27: Word = "Twenty-Seven"
Case Is = 28: Word = "Twenty-Eight"
Case Is = 29: Word = "Twenty-Nine"
Case Is = 30: Word = "Thirty"
Case Is = 31: Word = "Thirty-One"
Case Is = 32: Word = "Thirty-Two"
Case Is = 33: Word = "Thirty-Three"
Case Is = 34: Word = "Thirty-Four"
Case Is = 35: Word = "Thirty-Five"
Case Is = 36: Word = "Thirty-Six"
Case Is = 37: Word = "Thirty-Seven"
Case Is = 38: Word = "Thirty-Eight"
Case Is = 39: Word = "Thirty-Nine"
Case Is = 40: Word = "Forty"
Case Is = 41: Word = "Forty-One"
Case Is = 42: Word = "Forty-Two"
Case Is = 43: Word = "Forty-Three"
Case Is = 44: Word = "Forty-Four"
Case Is = 45: Word = "Forty-Five"
Case Is = 46: Word = "Forty-Six"
Case Is = 47: Word = "Forty-Seven"
Case Is = 48: Word = "Forty-Eight"
Case Is = 49: Word = "Forty-Nine"
Case Is = 50: Word = "Fifty"
Case Is = 51: Word = "Fifty-One"
Case Is = 52: Word = "Fifty-Two"
Case Is = 53: Word = "Fifty-Three"
Case Is = 54: Word = "Fifty-Four"
Case Is = 55: Word = "Fifty-Five"
Case Is = 56: Word = "Fifty-Six"
Case Is = 57: Word = "Fifty-Seven"
Case Is = 58: Word = "Fifty-Eight"
Case Is = 59: Word = "Fifty-Nine"
Case Is = 60: Word = "Sixty"
Case Is = 61: Word = "Sixty-One"
Case Is = 62: Word = "Sixty-Two"
Case Is = 63: Word = "Sixty-Three"
Case Is = 64: Word = "Sixty-Four"
Case Is = 65: Word = "Sixty-Five"
Case Is = 66: Word = "Sixty-Six"
Case Is = 67: Word = "Sixty-Seven"
Case Is = 68: Word = "Sixty-Eight"
Case Is = 69: Word = "Sixty-Nine"
Case Is = 70: Word = "Seventy"
Case Is = 71: Word = "Seventy-One"
Case Is = 72: Word = "Seventy-Two"
Case Is = 73: Word = "Seventy-Three"
Case Is = 74: Word = "Seventy-Four"
Case Is = 75: Word = "Seventy-Five"
Case Is = 76: Word = "Seventy-Six"
Case Is = 77: Word = "Seventy-Seven"
Case Is = 78: Word = "Seventy-Eight"
Case Is = 79: Word = "Seventy-Nine"
Case Is = 80: Word = "Eighty"
Case Is = 81: Word = "Eighty-One"
Case Is = 82: Word = "Eighty-Two"
Case Is = 83: Word = "Eighty-Three"
Case Is = 84: Word = "Eighty-Four"
Case Is = 85: Word = "Eighty-Five"
Case Is = 86: Word = "Eighty-Six"
Case Is = 87: Word = "Eighty-Seven"
Case Is = 88: Word = "Eighty-Eight"
Case Is = 89: Word = "Eighty-Nine"
Case Is = 90: Word = "Ninety"
Case Is = 91: Word = "Ninety-One"
Case Is = 92: Word = "Ninety-Two"
Case Is = 93: Word = "Ninety-Three"
Case Is = 94: Word = "Ninety-Four"
Case Is = 95: Word = "Ninety-Five"
Case Is = 96: Word = "Ninety-Six"
Case Is = 97: Word = "Ninety-Seven"
Case Is = 98: Word = "Ninety-Eight"
Case Is = 99: Word = "Ninety-Nine"
Case Is = 100: Word = "Hundred"
End Select
End Sub

Code in Userform1
Code:
Option Explicit

Private Sub TextBox1_Change()

   TextBox2.Text = UCase$(FigtoWords(Format(TextBox1.Text, "#.##")))

 If TextBox1.Text = "" And TextBox1.Text = "0.0" Then
      TextBox2.Text = ""
     End If

End Sub

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

Select Case KeyCode
Case Is = 13
  
  txtMidDigit.Text = "Mid Digit " + Digits
  txtLeftDigit.Text = Mid$(Paisa, 1, 1)
  txtRightDigit.Text = Mid$(Paisa, 2, 1)
End Select
End Sub

:banghead::banghead:
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I've worked for converting figures to words in the following manner and differently only after decimal
from the link with my previous thread 1031511-converting-figures-words-seems-correction-required
In keeping with Rule 12 (http://www.mrexcel.com/forum/board-announcements/99490-forum-rules.html), kindly don't ask the same question in multiple threads.

Thread closed. You may continue the discussion in your original thread (https://www.mrexcel.com/forum/excel...-figures-words-seems-correction-required.html).
 
Last edited:
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top