Can not assign 'Convert.ToDouble(row("Amount").ToString)

Hello,
performing the opeation you see below:
image
on following data I get the error you see:
DataRow { HasErrors=false, ItemArray=object[16] { “100000054”, @" Customer Name
“, @”
220", “28000464”, “STD”, “01-17-2023”, “03-01-2023”, “”, “USD”, “24.28-”, “24.28-”, “24.28-”, “24.28-”, “0”, @"
“, [03/01/2023 00:00:00] }, RowError=”", RowState=Added, Table=[TableName] }

Assign Amount & Balance Amount: Can not assign ‘Convert.ToDouble(row(“Amount”).ToString) + dblSumAmount’ to ‘dblSumAmount’.

“Amount” value is “24.28-” you see in the record.

I suppose it’s because is negative.
Do you know how to fix it?
Thanks.
Br.
Marco.

Hi,

Which do you need to handle “24.28-”, as positive or negative?

If positive

Convert.ToDouble(row("Amount").ToString.TrimEnd("-"c)) +dbSumAmount

If negative

Convert.ToDouble(System.Text.RegularExpressions.Regex.Replace(row("Amount").ToString,"^([.,\d]+)(-)?$","$2$1")) +dbSumAmount

Hope the above helps you.

Regards,

1 Like

Try to use this. This will only capture digits.

System.Text.RegularExpressions.Regex.Match(row(“Amount”)),“[.\d]+”).Value + dbSumAmount

Hope the above helps you

Regards,