+ 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.
3 Respostas
+ 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
+ 1
sneeze Label2 to be on User Control, how in the code to point to it?
+ 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.