Solved

Reading values from the settings.settings file.

Posted on 2012-03-29
2
265 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 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

691 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