Page 2 of 2

Re: Covert int to string

Posted: Tue Aug 06, 2013 5:10 am
by GoranW
I too need to convert an int to a string. I will also need to convert the other way, i.e. a string to an int. After looking in the forum I have tried this:

void RecipeNumber_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{

Globals.Tags.RecipeName.Value = Convert.ToString(Globals.Tags.RecipeNumber.Value);
}


I get a compilation error saying it is an ambguity between Convert.ToString(uint) and Convert.ToString(System.DateTime)

If I try this:
Globals.Tags.RecipeName.Value = System.Convert.ToString(5);

a "5" is displayed neatly on the Ix.

What am I doing wrong?

Re: Covert int to string

Posted: Tue Aug 06, 2013 6:14 am
by Edmund
Try

To String:

Globals.Tags.RecipeName.Value = Globals.Tags.RecipeNumber.Value.ToString();

To Int

Globals.Tags.MyIntTag.Value = Convert.ToInt32("123");

Re: Covert int to string

Posted: Tue Aug 06, 2013 6:37 am
by GoranW
Hi Edmund,
Tanks for the quick reply.
I managed to get it to work by using private variables, see screen dump.
But I will try your proposal too.

Thanks
Goran :D

Re: Covert int to string

Posted: Tue Aug 06, 2013 8:19 am
by Edmund
Great Göran :)

The iX tag class also includes convert/cast functions (if possible), see image below
tag_cast.png
tag_cast.png (14.15 KiB) Viewed 7585 times