I'm doing a course on learning C# and the task is to create a small converter using windows forms and use a function to perform the conversion.
At the moment I have been able to do everything through defining a variable in the form and having each different button assign a value to the variable, This works fine at the moment since the conversion is happening within an event when the convert button is pushed. But to complete the task I need the conversion to place outside of the form.
The issue I have is I can't figure out how to access the variable I declared within the form and I don't know how I would return the value into the form once I have created the function.
I'm guessing the function would look something like
public double conversion(string ConvertIn, string ConvertOut, double Value)
{
Value = Double.Parse(ValueEntry.Text);
double Output = (Value / Double.Parse(ConvertIn)) * Double.Parse((ConvertOut));
FinalOutput.Text = Convert.ToString(Output);
{
return Output;
}
return 0;
}
But as I said I can't figure out how to get the 3 variables that have been declared in the form, or how I would return the value into the form output box.
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire