I created a program to read/write with data from another program. I set a value of 7 (of type memory real) in the program, then when I read the value in visual studio, it gives me a string 7.0000000000000. So I created this conversion snippet which works for data of type int which also gives me a string in VS. I don’t know the difference between these 2 data types but logically if both data types give me a string, I should be able to run this code. Why the memory real data skips the if here?
if (Regex.IsMatch(value, "^[0-9 ]+$"))
{
ValueBox.Text = Double.Parse(value).ToString();
}
else
{
ValueBox.Text = value;
}
EDIT: I use 2 given dlls, I believe there is a conversion issue in the dll but my code should still work.
EDIT 2: This code is a section from my program, value and other variables are already defined
Skip the Regex and use TryParse
Double.TryParse Method
Int32.TryParse Method
or can just format “N0”
d.ToString(“N0”)