Solved

Creating Color Dialog

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

Accepted Solution

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

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
Thank you both!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

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…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now