Getting an Unhandled Exception:
Here's a screen shot:

[IMG]http://i25.tinypic.com/344d28l.jpg[/IMG]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Chapter2Program3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            while (Visible)
            {
                for (int c = 0; c < 254 && Visible; c++)
                {
                    this.BackColor = Color.FromArgb(c, 225 - c, c);

                    Application.DoEvents();
                    
                    System.Threading.Thread.Sleep(3);
                }

                for (int c = 254; c >= 0 && Visible; c--)
                {
                    this.BackColor = Color.FromArgb(c, 225 - c, c);

                    Application.DoEvents();

                    System.Threading.Thread.Sleep(3);
                }
            }
        }
    }
}

Recommended Answers

All 2 Replies

You need to use 255 instead of 225.

this.BackColor = Color.FromArgb(c, 255 - c, c);

How could've been so blind....
Thanks for the help ^_^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.