Click here to Skip to main content
15,040,212 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to Convert number to their Devanagari equivalent in crystal report,

Below is the code I'm using in Crystal Report Formula Field
Local StringVar Source;
Source ="12345";
Local StringVar Array Find[9] = ["0", "1", "2", "3", "4", "5", "6", "7", 

"8", "9"];
Local StringVar Array ReplaceWith[9] = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"];
Local NumberVar i;
For i := 0 To 9 Do
(
    Source=Replace(Source,Find[i],ReplaceWith[i]);
);
Source


I'm getting the following error
---------------------------
Crystal Report Windows Forms Viewer
---------------------------
A subscript must be between 1 and the size of the array.
Error in File C:\Users\#####\AppData\Local\Temp\temp_399eec96-2351-4673-a737-5184c655276c {0E96E068-8B69-4239-8CC0-CB376BA9A048}.rpt:
Error in formula  <substituteFunction>. 
'Local StringVar Result;
'
A subscript must be between 1 and the size of the array.
---------------------------
OK   
---------------------------


Please tell me what I'm doing wrong?
Posted

1 solution

I hit that at some point, too. Crystal Reports formulas evidently operate with 1-based arrays instead of 0, so the problem's in your loop. Try:
For i := 1 To 10 Do
(
    Source=Replace(Source,Find[i],ReplaceWith[i]);
);
   
Comments
Firdaus Shaikh 10-Jul-13 6:31am
   
Thank you woopsydoozy,
It worked and I've accepted your answer,

Firdaus Shaikh.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900