?
Solved

Reading values from the settings.settings file.

Posted on 2012-03-29
2
Medium Priority
?
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

765 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