Solved

Creating Color Dialog

Posted on 2008-06-16
3
1,937 Views
Last Modified: 2013-11-27
I'm new to VB programming, and am watching the Teir 1 tutorial provided by Microsoft (http://msdn.microsoft.com/en-us/beginner/bb308891.aspx). I'm trying to make a button which opens a color dialog box and changes the background color of the window based off the color chosen in the dialog box. Unfortunately, even coding it exactly the way it is in the tutorial, I get debug errors.

My Errors:

Error      1      Name 'ColorDialog1' is not declared.      C:\Users\mangin\Documents\Visual Studio 2008\Projects\WindowsApplication2\WindowsApplication2\Form1.vb      3      9      WindowsApplication2

Error      2      Name 'ColorDialog1' is not declared.      C:\Users\mangin\Documents\Visual Studio 2008\Projects\WindowsApplication2\WindowsApplication2\Form1.vb      4      24      WindowsApplication2


I don't understand how the girl in the tutorial has no problems with this exact coding. Any suggestion helps.
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ColorDialog1.ShowDialog()
        Me.BackColor = ColorDialog1.Color
    End Sub
End Class

Open in new window

0
Comment
Question by:Chris-Manginelli
[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
3 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 125 total points
ID: 21796257
Y0u need to declare ColorDialog1. Under line 1 put
Dim ColorDialog1 As New ColorDialog()
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 21796528
Or you can add a ColorDialog onto your form (instead of declaring one locally...but either way is fine!).  It's in the section of the ToolBox labled "Dialogs":

ColorDialog.jpg
0
 

Author Comment

by:Chris-Manginelli
ID: 21796964
Thank you both!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 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