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
Solved

Reading values from the settings.settings file.

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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