Reputation: 1
I have a Colum with in a dataGridview with Amount in the format “5 187.00” I am trying to sum-up the Colum and have the result in a viable but what happens is , the system only picks the value “5” not “5,187.00” as I expected. So I am thinking the space in between 5 and 1 is the problem. My question is how do I prevent the space, or convert the entry to decimal.
I have tried using
Dim num as String
Num = “5 187.00”
Num =num.Replace(“ ”, “”)
Cell value = Num
But this no not responding Let me know if anyone can help.
Thank you
Upvotes: 0
Views: 189
Reputation: 12781
We are not sure what space it is. (can be a tab also)
Use Regex
class as shown in below example
Dim num As String = "5 678.90"
Dim cellValue As Decimal = 0.0
num = Regex.Replace(num, "\s", "")
cellValue = Convert.ToDecimal(num)
You have to import
Imports System.Text.RegularExpressions
Upvotes: 0