I want to create a bot which find the format of price from excel and then give result according to that.
like:
amount in excel is = 10000 the result should be 10.000,00
OR
amount in excel is = 10.000 the result should be 10.000,00
OR
amount in excel is = 10.000,00 then it shoud stay as it is 10.000,00
For Each row As DataRow In dt.Rows
Dim raw As String = row(0).ToString().Trim()
' Remove all symbols except digits, . , and -
raw = Regex.Replace(raw, "[^\d\.,\-]", "")
' Convert:
' If comma exists → treat as decimal separator
' Else → treat as integer without thousands separators
Dim normalized As String =
If(raw.Contains(","c),
raw.Replace(".", "").Replace(",", "."),
raw.Replace(".", "")
)
' Parse using invariant culture
Dim numberValue As Decimal =
Decimal.Parse(normalized, System.Globalization.CultureInfo.InvariantCulture)
' Convert to European (de-DE) format → 10.000,00
row(0) = numberValue.ToString("N2", System.Globalization.CultureInfo.GetCultureInfo("de-DE"))
Next
What it does is to check if there is a comma and if yes then check if the is before or after the dot. This way it finds out if it is in us format or european format.