Skip to Content
0
Former Member
Jun 04, 2008 at 12:14 PM

Need Help on UDF

24 Views

Hi All,

I have a small requirement where i want to find the underscore and then put additional zeros to it.

ex:

0041234567_123456789123

Now i just want to find the underscore( "_") and calculate the number of characters from left and if it is less than 13 i should added zeros to it.

i.e. find the number of characters before underscore("_")

= 10 characters(0041234567)

pick those 10 characters(0041234567)

add zeros to it from left (0000041234567)

return the result as 0000041234567_123456789123

I have written the function to add zeros to it, i just want the code to find the underscore and add zeros from left.

code:

int n;

int v;

String str ;

for ( int i =0 ;i<a.length; i++)

{

str = "0";

v = a<i>.length();

n =13 -a<i>.length();

for ( int k = 0;k< (n-1); k ++)

str = str +"0";

if ( v ==13)

result.addValue(a<i>);

else

{

a<i> = str+a<i>;

result.addValue(a<i>);

}

}

Thanks a lot in advance.

JGD.