Suppose you need to show your given number in words like this,
First, you have to create a Class like this(below),
Public Class NumberInWord
Public Shared SpaceString As String = " "
Public Enum RootNumbers
Zero = 0
One = 1
Two = 2
Three = 3
Four = 4
Five = 5
Six = 6
Seven = 7
Eight = 8
Nine = 9
Ten = 10
Eleven = 11
Twelve = 12
Thirteen = 13
Fourteen = 14
Fifteen = 15
Sixteen = 16
Seventeen = 17
Eighteen = 18
Nineteen = 19
Twenty = 20
Thirty = 30
Forty = 40
Fifty = 50
Sixty = 60
Seventy = 70
Eighty = 80
Ninety = 90
Hundred = 100
Thousand = 1000
Lakhs = 100000
Crore = 10000000
End Enum
Public Shared Function GetRootNumberWord(ByVal number As Integer) As String
Dim myNumberWord = [Enum].GetName(GetType(RootNumbers), number)
'If myNumberWord.Equals("Zero") Then
' myNumberWord = " "
'End If
Return myNumberWord
End Function
Public Shared Function GetSourcesNumber(number As Decimal) As Dictionary(Of String, String)
Dim myMoneyInSrt As String = number.ToString
Dim dictionary As New Dictionary(Of String, String)
Dim result As New System.Text.StringBuilder
' dictionary.Add(3, True)
' dictionary.Add(5, False)
If myMoneyInSrt.Length > 9 Then
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
dictionary.Add("ThousandsValue", "")
dictionary.Add("HundredsValue", "")
dictionary.Add("TensValue", "")
dictionary.Add("UnitsValue", "")
End If
If myMoneyInSrt.Length = 9 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 2)) '981485145
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("CroresValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("CroresValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(2, 2))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(4, 2))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(6, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(7, 1))
'result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(8, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 8 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("CroresValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("CroresValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(1, 2))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(3, 2))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(5, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString) '8 14 85 145
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(6, 1))
'result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(7, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 7 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 2))
dictionary.Add("CroresValue", "")
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(2, 2))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("ThousandsValue", result.ToString) '14 85 1 45
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(4, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(5, 1))
'result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(6, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 6 Then
dictionary.Add("CroresValue", "")
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("LacsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(1, 2))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(3, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(4, 1))
'result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(5, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 5 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 2))
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(2, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(3, 1))
'result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(4, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 4 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 1))
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("ThousandsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(1, 1))
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(2, 1))
'result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(3, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 3 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 1)) '1 23
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
dictionary.Add("ThousandsValue", "")
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("HundredsValue", result.ToString)
result.Clear()
End If
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(1, 1))
' result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(GetRootNumberWord(myNumber))
result.Append(SpaceString)
'result.Append(GetRootNumberWord(myNumber Mod 10))
dictionary.Add("TensValue", result.ToString)
result.Clear()
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(2, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 2 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 1)) '1 2
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
dictionary.Add("ThousandsValue", "")
dictionary.Add("HundredsValue", "")
If myNumber > 20 Then
result.Append(GetRootNumberWord((myNumber \ 10) * 10))
result.Append(SpaceString)
dictionary.Add("TensValue", result.ToString)
result.Clear()
Else
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("TensValue", result.ToString)
result.Clear()
End If
If myNumber >= 1 Then
myNumber = Convert.ToInt32(myMoneyInSrt.Substring(1, 1))
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
result.Clear()
Else
dictionary.Add("UnitsValue", "")
End If
End If
If myMoneyInSrt.Length = 1 Then
Dim myNumber As Integer = Convert.ToInt32(myMoneyInSrt.Substring(0, 1)) '1
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
dictionary.Add("ThousandsValue", "")
dictionary.Add("HundredsValue", "")
dictionary.Add("TensValue", "")
result.Append(GetRootNumberWord(myNumber))
dictionary.Add("UnitsValue", result.ToString)
End If
If myMoneyInSrt.Length = 0 Then
dictionary.Add("CroresValue", "")
dictionary.Add("LacsValue", "")
dictionary.Add("ThousandsValue", "")
dictionary.Add("HundredsValue", "")
dictionary.Add("TensValue", "")
dictionary.Add("UnitsValue", "")
End If
Return dictionary
End Function
End Class
Finally, you call this Class where you want to use it to set Excel Cell Value.
Dim dictionary As New Dictionary(Of String, String)
dictionary = NumberInWord.GetSourcesNumber(Round((YourNumber), 0))
Excel.Cells((10), 2) = dictionary.Item("CroresValue")
Excel.Cells((10), 4) = dictionary.Item("LacsValue")
Excel.Cells((10), 6) = dictionary.Item("ThousandsValue")
Excel.Cells((10), 9) = dictionary.Item("HundredsValue")
Excel.Cells((10), 12) = dictionary.Item("TensValue")
Excel.Cells((10), 15) = dictionary.Item("UnitsValue")
//Where Excel.Cells((10), 15) is Your Excel Column(10) And Row(15) No where you set converted Value.