Solved

Reading values from the settings.settings file.

Posted on 2012-03-29
2
258 Views
Last Modified: 2012-03-29
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
0
Comment
Question by:peterkiers
2 Comments
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 500 total points
ID: 37780528
Try to convert the values to integer like

if (intVal  > Convert.ToInt32(Properties.Settings.Default.MinVal))
....
0
 
LVL 1

Author Comment

by:peterkiers
ID: 37780558
Thanks. 500 points are comming your way...
P.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now