Solved

Converting problem in a methode.

Posted on 2012-03-24
2
232 Views
Last Modified: 2012-03-25
Dear Experts,

I programm in VS2010 and I use C#. I have this code but it has an error.
I have marked the codeline with an arrow that has the error :

        private void btnSwUnit_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.IsMGDL = !Properties.Settings.Default.IsMGDL;
            Properties.Settings.Default.Save();
            if (Properties.Settings.Default.IsMGDL)
            {
                btnSwUnit.Text = "Switch to mmol/l";
                lblSwUnit.Text = "Glucose Units: mg/dl";

                int eValInt = Convert.ToInt32(spdMinVal.Value) / 18;
                spdMinVal.Value = eValInt;
            }
            else
            {
                btnSwUnit.Text = "Switch to mg/dl";
                lblSwUnit.Text = "Glucose Units: mmol/l";

                double eValue = Convert.ToDouble(spdMinVal.Value) * 18; 
                spdMinVal.Value = eValue; <==========

            }
        }

Open in new window


Error:
"Cannot implicitly convert type 'double' to 'decimal'. An explicit conversion exists (are you missing a cast?)".

How can I solve 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 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37760848
Change:

    spdMinVal.Value = eValue;

To:

    spdMinVal.Value = (decimal)eValue;
0
 
LVL 1

Author Comment

by:peterkiers
ID: 37762296
Thanks. P.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…

751 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