?
Solved

Creating Color Dialog

Posted on 2008-06-16
3
Medium Priority
?
1,948 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 500 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

801 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