100% * label2 / label3, how to enter it so that bi the amount of output in label4? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

100% * label2 / label3, how to enter it so that bi the amount of output in label4?

Hello, there is label2 (in it the numbers are written), and label3 (in it, too, the numbers are written), there is a formula: 100% * label2 / label3, how to enter it so that bi the amount of output in label4? Need for windows form.

19th Jan 2020, 4:48 PM
olmtvck
olmtvck - avatar
3 Answers
+ 2
In winform The value of a label is in "label2.text" This is a string, to convert the string to a number use Convert.ToInt32(label2.text); Because a division can create a floating point number, use the float-type for the variable number4. Represent number4 in a label use number4.ToString(); https://code.sololearn.com/cgD3H4h5wR5t
19th Jan 2020, 9:26 PM
sneeze
sneeze - avatar
+ 1
sneeze Label2 to be on User Control, how in the code to point to it?
20th Jan 2020, 7:50 PM
olmtvck
olmtvck - avatar
+ 1
Make a property in the custom control. Then you can use customcontrol.label2value in your code. This is the code in the customcontrol. private int _label2value public int label2value { get { return _label2value;} set { _label2value = value;} } Make sure that when label2 is changed you set the value of _label2value. https://www.dotnetperls.com/property https://www.c-sharpcorner.com/article/understanding-properties-in-C-Sharp/ https://www.w3schools.com/cs/cs_properties.asp Keep coding, keep asking. You are doing well.
20th Jan 2020, 8:45 PM
sneeze
sneeze - avatar