c# - How to divide a string value by another string value, each containing a numeric value -
how make label display numericupdown1
/ numericupdown2
properly?
here have
label6.text = convert.tostring(numericupdown1.value/numericupdown2.value);
i have tried
label6.text = numericupdown1.value/numericupdown2.value
and got error saying
cannot implicitly convery blah blah bytes
an after start project crashes ( have project opens tries display numud1
/ numud2
...
in simple terms:
decimal d = (numericupdown1.value/numericupdown2.value); stringval = system.convert.tostring(d); label6.text = stringval;
or create subclass of numericupdown , override parsevalue method (as seen here):
public class mynumericupdown : numericupdown { protected override double parsevalue(string text) { // change text whatever want string newtext = fixtext(text); // call base implementation. base.parsevalue(newtext); } private static string fixtext(string inputtext) { // stuff here. } }
Comments
Post a Comment