Solved

Creating Color Dialog

Posted on 2008-06-16
3
1,928 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Winform not working on 64 bit machine 31 104
Microsoft Query from QuickBooks 9 76
Visual Studio Debugging 3 153
Why is "packages element is not declared"? 2 465
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…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 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