Please Help me to fix: in my RDLC file i have given a text box to generate the amount value in word. Its doing every thing correct but when i am generating amount like 15,000.00 its showing "Ten Thousand" or when i am giving amount as 115,000.00 its showing "One hundred Ten Thousand" & its goes on for 215,000.00 or 315,000.00
Here is my code:
````Function SpellNumber(ByVal MyNumber As Decimal, ByVal Currency As String) As String
Dim Dollars As String
Dim Cents As String
Dim Temp As String
Dim DecimalPlace As Integer
Dim Count As Integer
Dim Place(5) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
Dim MyNumberStr As String = CStr(MyNumber)
DecimalPlace = InStr(MyNumberStr, ".")
If DecimalPlace > 0 Then
Cents = " & " & Mid(MyNumberStr, DecimalPlace + 1, 2) & "/100"
MyNumberStr = Left(MyNumberStr, DecimalPlace - 1)
Else
Cents = "& XX/100"
End If
Count = 1
Do While MyNumberStr <> ""
Temp = GetHundreds(Right(MyNumberStr, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumberStr) > 3 Then
MyNumberStr = Left(MyNumberStr, Len(MyNumberStr) - 3)
Else
MyNumberStr = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = " "
Case "One"
Dollars = " "
Case Else
Dollars = StrConv(Dollars, VbStrConv.ProperCase) & " "
End Select
' Concatenate the Currency field value with the spelled-out amount
SpellNumber = Currency & " " & Dollars & Cents
End Function
Function GetHundreds(ByVal MyNumber) As String
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
Function GetTens(TensText) As String
Dim Result As String
Result = ""
If Val(Left(TensText, 1)) = 1 Then
Select Case Val(TensText)
Case 10 To 19
Result = "Ten"
Case Else
End Select
Else
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
End Select
Result = Result & GetDigit(Right(TensText, 1))
End If
GetTens = Result
End Function
Function GetDigit(Digit) As String
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four "
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function`
Generate correct amount