I've tried to make my tool display a field into % by doing some math then converting it.
Here is my code and what I would like to do is these things.
If the result is a value that comes out to a flat % then display the flat % example result of calculation comes out to 3% then show 3% otherwise if it's a decimal show 3.1% and one for if the value becomes less than 1% so .5 or .05 for example.
A little background for the code. the value tbOptionlvl5 will have a value out of 10,000 . 10,000 being 100% so the example might be lets say 510.
if (Item_Is_Rare() && int.Parse(TbOptionID5.Text) >= 0)
{
lblProb5.Text = "";
decimal result = ((int.Parse(TbOptionLvl5.Text) * 100) / 10000);
lblProb5.Text = Convert.ToString(result) + "%";
}
here is my code for calling the function
if (TbOptionID10.Text == "-1")
lblProb10.Text = "";
if (TbOptionID10.Text != "-1" && TbOptionID10.Text != "")
{
if (int.Parse(TbOptionID10.Text) > 10000)
TbOptionID10.Text = Convert.ToString(10000);
Update_Probability_Text();
}