P
Pascal
hello everybody !
I get this error 3 times : "The output parameter must be assigned before
the control leaves the current method" (dor dMin and dMax)
this one 1 time : Use of the parameter 'out' is not assigned 'dMax'
This is my first steps in C#: i can't manage(understand) this error.
I would like to test to variables which can be change on form1 by 2 numeric
updown controls before sending them to a UserControl which make some
calculation with these 2 numbers like this :
if (_genData.NumberMin < _genData.NumberMax)
{
S = (int)(_rand.Next((int)_genData.NumberMin,
(int)_genData.NumberMax + 1) / 3) * 3;
}
else
{
//Choisir le nombre cible (_iS) compris dans la fourchette
et le rendre multiple de trois.
// Set the target number (_iS) in the range and make
multiple of three.
So if user modify the value and nudNumMin .Value becomes > nudNumMax
..Value the calculation could send an error in calculating the value S.
That's why i have to test and correct the values before sending them to the
UserControl.
the code in form1 is :
#region min max check
string message = "Attention ! Le nombre maximal doit être > au
nombre minimal. L'erreur sera corrigée";
string caption = "Erreur dans le choix de la taille des nombres.";
MessageBoxButtons buttons = MessageBoxButtons.OK;
DialogResult result;
// this method checks the values and shows an error message if
// they are not as expected and corrects them to a valid state
public bool CheckMinMaxValues(out int dMin, out int dMax)
{
if ( nudNumMin .Value > nudNumMax .Value )
{
result = MessageBox.Show(message, caption, buttons);
dMin = dMax - 1;
return false;
}
return true;
}
#endregion //min max check
and then :
private void nudNumMax_ValueChanged( object sender, EventArgs e )
{
int dMin = (int)nudNumMin.Value;
int dMax = (int)nudNumMax.Value;
if (!CheckMinMaxValues(out dMin, out dMax))
{
//... do what ever is needed when the check fails
nudNumMin.Value = dMin;
nudNumMax.Value = dMax;
nudNumMax.Value = nudNumMin.Value + 1;
_currParam.GenerationData.NumberMax = (int) nudNumMin.Value
+ 1; // for example
}
_currParam.GenerationData.NumberMax = (int)nudNumMax.Value;
ValueChanged( true );
}
I hope you understand me....
and can help me !
pascal
I get this error 3 times : "The output parameter must be assigned before
the control leaves the current method" (dor dMin and dMax)
this one 1 time : Use of the parameter 'out' is not assigned 'dMax'
This is my first steps in C#: i can't manage(understand) this error.
I would like to test to variables which can be change on form1 by 2 numeric
updown controls before sending them to a UserControl which make some
calculation with these 2 numbers like this :
if (_genData.NumberMin < _genData.NumberMax)
{
S = (int)(_rand.Next((int)_genData.NumberMin,
(int)_genData.NumberMax + 1) / 3) * 3;
}
else
{
//Choisir le nombre cible (_iS) compris dans la fourchette
et le rendre multiple de trois.
// Set the target number (_iS) in the range and make
multiple of three.
So if user modify the value and nudNumMin .Value becomes > nudNumMax
..Value the calculation could send an error in calculating the value S.
That's why i have to test and correct the values before sending them to the
UserControl.
the code in form1 is :
#region min max check
string message = "Attention ! Le nombre maximal doit être > au
nombre minimal. L'erreur sera corrigée";
string caption = "Erreur dans le choix de la taille des nombres.";
MessageBoxButtons buttons = MessageBoxButtons.OK;
DialogResult result;
// this method checks the values and shows an error message if
// they are not as expected and corrects them to a valid state
public bool CheckMinMaxValues(out int dMin, out int dMax)
{
if ( nudNumMin .Value > nudNumMax .Value )
{
result = MessageBox.Show(message, caption, buttons);
dMin = dMax - 1;
return false;
}
return true;
}
#endregion //min max check
and then :
private void nudNumMax_ValueChanged( object sender, EventArgs e )
{
int dMin = (int)nudNumMin.Value;
int dMax = (int)nudNumMax.Value;
if (!CheckMinMaxValues(out dMin, out dMax))
{
//... do what ever is needed when the check fails
nudNumMin.Value = dMin;
nudNumMax.Value = dMax;
nudNumMax.Value = nudNumMin.Value + 1;
_currParam.GenerationData.NumberMax = (int) nudNumMin.Value
+ 1; // for example
}
_currParam.GenerationData.NumberMax = (int)nudNumMax.Value;
ValueChanged( true );
}
I hope you understand me....
and can help me !
pascal