For Each row As DataRow In dt.Rows
Dim amount1 As Double = 0
Dim amount2 As Double = 0
If Double.TryParse(row("Amount1").ToString().Replace("$", "").Replace(",", "").Trim(), amount1) = False Then
amount1 = 0
End If
If Double.TryParse(row("Amount2").ToString().Replace("$", "").Replace(",", "").Trim(), amount2) = False Then
amount2 = 0
End If
row("Difference") = amount1 - amount2
Next
For Each Row in DataTable
Activity: For Each Row
DataTable: filter_Status1
Inside the For Each Row Activity:
First Assign Activity:
To: row(“Bal Amt”)
Value: row(“Bal Amt”).ToString().Replace(“$”, “”).Trim()
Second Assign Activity:
To: row(“Pat Amt”)
Value: row(“Pat Amt”).ToString().Replace(“$”, “”).Trim()
Third Assign Activity:
To: row(“Bal Amt”)
Value: If(IsNumeric(row(“Bal Amt”)), CDbl(row(“Bal Amt”)), 0)
Fourth Assign Activity:
To: row(“Pat Amt”)
Value: If(IsNumeric(row(“Pat Amt”)), CDbl(row(“Pat Amt”)), 0)
Fifth Assign Activity:
To: row(“(B-P) Amt”)
Value: CDbl(row(“Bal Amt”)) - CDbl(row(“Pat Amt”))
This approach ensures that:
Dollar signs and other non-numeric characters are removed from the Bal Amt and Pat Amt values.
The values are checked to ensure they are numeric before performing the subtraction.
The result of the subtraction is stored in the (B-P) Amt column.