The problem is in your
ToNumber
function and the way you are extracting the numbers.
There are a few ways of doing it - these samples are in C# but you should get the idea...
If you are able to use Linq then
private string ToNumber1(string parm)
{
var num = parm.ToCharArray().Where(c => Char.IsDigit(c)).ToArray();
return new String(num);
}
If you are able to use Regex then
private string ToNumber2(string parm)
{
var num = Regex.Match(parm, @"\d+").Value;
return num;
}
Worst case scenario you can step through the string extracting the numbers "manually"
private string ToNumber3(string parm)
{
string num = string.Empty;
for (int i = 0; i < parm.Length; i++)
if (char.IsDigit(parm[i]))
num += parm[i];
return num;
}
Alternatively, post the code for
your ToNumber function and I'll see if I can fix it.
In Crystal Syntax the function would look something like this (Warning - not tested nor syntax checked)
Local StringVar num := "";
Local NumberVar i;
For i := 0 To Length(Parm) - 1 Do
(
Local StringVar parmChar := parm [i];
Local BooleanVar isDigit := parmChar in "0" to "9";
If IsDigit Then
(
num := num + parmChar;
)
);
num