Professional Documents
Culture Documents
1.Open the Report Design and Paste the above custom code in Report Properties->Code tab as
below
2.Go to Particular Field(text box) in report design and right click the text box-> click on expression
and write the expression as below:
3.Build the project , and deploy the reports. See the changes in the Report at Front end
Conversion of Amount to Words(English) in SSRS Ax Reports
Public Shared Function changeToWords(ByVal numb As [String]) As [String]
Dim val As [String] = "", wholeNo As [String] = numb, points As [String] = "", andStr As [String] = "", pointStr As
[String] = ""
Dim endStr As [String] = ""
Try
Dim decimalPlace As Integer = numb.IndexOf(".")
If decimalPlace > 0 Then
wholeNo = numb.Substring(0, decimalPlace)
points = numb.Substring(decimalPlace + 1)
If Convert.ToInt32(points) > 0 Then
andStr = " And"
' just to separate whole numbers from points
pointStr = translateCents(points)
End If
End If
val = [String].Format("{0} {1}{2} {3}{4}", translateWholeNumber(wholeNo).Trim()," Rupees", andStr, pointStr,
endStr)
Catch
End Try
Return val
End Function
Private Shared Function translateWholeNumber(ByVal number As [String]) As [String]
Dim word As String = ""
Try
Dim beginsZero As Boolean = False
'tests for 0XX
Dim isDone As Boolean = False
'test if already translated
Dim dblAmt As Double = (Convert.ToDouble(number))
'if ((dblAmt > 0) && number.StartsWith("0"))
If dblAmt > 0 Then
'test for zero or digit zero in a nuemric
beginsZero = number.StartsWith("0")
End Try
Return word.Trim()
End Function
Private Shared Function tens(ByVal digit As [String]) As [String]
Dim digt As Integer = Convert.ToInt32(digit)
Dim name As [String] = Nothing
Select Case digt
Case 10
name = "Ten"
Exit Select
Case 11
name = "Eleven"
Exit Select
Case 12
name = "Twelve"
Exit Select
Case 13
name = "Thirteen"
Exit Select
Case 14
name = "Fourteen"
Exit Select
Case 15
name = "Fifteen"
Exit Select
Case 16
name = "Sixteen"
Exit Select
Case 17
name = "Seventeen"
Exit Select
Case 18
name = "Eighteen"
Exit Select
Case 19
name = "Nineteen"
Exit Select
Case 20
name = "Twenty"
Exit Select
Case 30
name = "Thirty"
Exit Select
Case 40
name = "Fourty"
Exit Select
Case 50
name = "Fifty"
Exit Select
Case 60
name = "Sixty"
Exit Select
Case 70
name = "Seventy"
Exit Select
Case 80
name = "Eighty"
Exit Select
Case 90
name = "Ninety"
Exit Select
Case Else
If digt > 0 Then
name = (tens(digit.Substring(0, 1) & "0") & " ") + ones(digit.Substring(1))
End If
Exit Select
End Select
Return name
End Function
Private Shared Function ones(ByVal digit As [String]) As [String]
Dim digt As Integer = Convert.ToInt32(digit)
Dim name As [String] = ""
Select Case digt
Case 1
name = "One"
Exit Select
Case 2
name = "Two"
Exit Select
Case 3
name = "Three"
Exit Select
Case 4
name = "Four"
Exit Select
Case 5
name = "Five"
Exit Select
Case 6
name = "Six"
Exit Select
Case 7
name = "Seven"
Exit Select
Case 8
name = "Eight"
Exit Select
Case 9
name = "Nine"
Exit Select
End Select
Return name
End Function
Private Shared Function translateCents(ByVal cents As [String]) As [String]
Dim cts As [String] = "", digit As [String] = "", engOne As [String] = ""
If cents.Equals("00") Then
engOne = ""
Else
engOne = tens(cents)
End If
cts += " " & engOne & " Paise"
Return cts
End Function
1.Open the Report Design and Paste the above Custom code in Report Properties->Code tab
2. Go to Particular Field(text box) in report design and right click the text box-> click on expression
and write the expression as below:
3. Build the Project, Deploy the Reports and See the Changes in the Report at Front End.