Solved

Change color on controls

Posted on 1998-09-01
6
126 Views
Last Modified: 2010-04-30
With the commondialog control I want to change the colors of command buttons, labels, etc.  The code I was given works great for fonts but I get error messages when i apply it to colors.

Form3!dlg.ShowColor

Dim myControl As CommandButton'  this does not work even If I put control or label here!


On Error GoTo Trap
For Each myControl In Form1
   
myControl.BackColor = Form3!dlg.Color

Next
   'Exit here
Trap:
     Err.Clear
   Resume Next

thanks
0
Comment
Question by:check1
6 Comments
 
LVL 6

Expert Comment

by:anthonyc
ID: 1432406
Not all controls have a settable backcolor.....  commandbuttons being one of them unless the style is set to graphical!
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1432407
check1,
you have an error before the code "on error goto ..."

Form3!dlg.ShowColor should be form3.dlg.showcolor?

Dim myControl as Control is OK.

What error message you get?

0
 
LVL 9

Expert Comment

by:Dalin
ID: 1432408
What anthonyc said is true... But it is OK because of your errortrapping. When no back color, error occurs, and it will automatically clear the error and goto the next control.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 9

Accepted Solution

by:
Dalin earned 30 total points
ID: 1432409
check1,
I just tried this and it works.
Drop a command in form1 and name it command1

Private Sub Command1_Click()

Form3.cdg.ShowColor

Dim myCOntrol As Control

On Error GoTo Trap

For Each myCOntrol In Form1
    myCOntrol.BackColor = Form3.cdg.Color
    Next
Exit Sub
   
Trap:
    Err.Clear
    Resume Next
   
End Sub

0
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1432410
I don't know, I can just say If I use the same code for fonts it works, let me try you suggesion.

Check1
0
 

Author Comment

by:check1
ID: 1432411
Thanks!

CHECK!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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