Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Reading values from the settings.settings file.

Hi,

I have this methode:

        private void edtVal1_Validating(object sender, CancelEventArgs e)
        {
            if (Properties.Settings.Default.IsMGDL)
            {
                int intVal = Convert.ToInt32(spdVal1.Text);
                if (intVal < 70 || intVal >= 140)          <===========
                {
                    XtraMessageBox.Show("The value must be between 70 and 140", "Error");
                }
            }
            else
            {
                double doubleVal = Convert.ToDouble(spdVal1.Text);
                if (doubleVal < 1.0 || doubleVal >= 35.0)   <===========
                {
                    XtraMessageBox.Show("The value must be between 1.0 and 35.0", "Error");
                }
            }
        }

Open in new window


My question is about the values in the code line that I have marked with an arrow.
Instead of specifying values I would like to read the values from the settings.settings-file.

Like this:

if (intVal < Properties.Settings.Default.MinVal || intVal >= Properties.Settings.Default.MaxVal)

Open in new window


But I get errors:

Operator '<' cannot be applied to operands of type 'int' and 'string'      
Operator '>=' cannot be applied to operands of type 'int' and 'string'      

What can I do about this?

Greetings,

Peter Kiers
ASKER CERTIFIED SOLUTION
Avatar of Kiran Sonawane
Kiran Sonawane
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

Thanks. 500 points are comming your way...
P.