Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 2nd, 2005, 3:37 AM   #1
fox123
Newbie
 
Join Date: Mar 2005
Posts: 25
Rep Power: 0 fox123 is on a distinguished road
Angry Colour Changing At Runtime

The title may seem simple but has been very frustrating.T his is what i need to do.:

As My Startup Object i have a form that has 4 different colour pictures. When the user clicks these i would like that to be the backcolour of all forms to be displayed. I have used this code:

Private Sub Image4_Click
frmWelcome.BackColor = vbBlue
Label1.BackColor = vbBlue
Label1.ForeColor = vbBlack
call ColourBlue
End Sub

I have put the procedure ColoyrBlue in a module:


frm1.backcolor = vbblue
frm2.backcolor = vbblue
frm3.baccolor = vbblue

But when this code is put in place it changes the colour of one form but no others also when i go back on a form the colour stays the standard colour.

Hope you can help
fox123 is offline   Reply With Quote
Old May 2nd, 2005, 4:14 AM   #2
melwinator
Newbie
 
Join Date: Mar 2005
Posts: 11
Rep Power: 0 melwinator is on a distinguished road
Declare a global variable that will hold the current selected colour and assign that colour to the backcolor property of each form load.

eg.

In the module do this
Dim varBColor as variant

sub main()
      varBColor=#000ff0    ' Set this to the default color
end sub

on image click do this


varBColor=vbBlue        ' Or whatever color u  want

on each form load do this

private Sub Form_Load()
      form1.BackColor=varBColor
end sub
That should do it... Hope this solved your problem........
You can always ask Rory !!!! He's the God of VB
melwinator is offline   Reply With Quote
Old May 2nd, 2005, 7:36 AM   #3
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Quote:
Originally Posted by melwinator
You can always ask Rory !!!! He's the God of VB
LOL! Anyway what you said's good, just:
varBColor=&H000ff0    ' Set this to the default color
&H is used in VB for hex
Public varBColor as Long
best to use the native type and also you'd need to make it public so you could access it.
Rory is offline   Reply With Quote
Old May 2nd, 2005, 12:42 PM   #4
fox123
Newbie
 
Join Date: Mar 2005
Posts: 25
Rep Power: 0 fox123 is on a distinguished road
Thanks To Everyone that helped.
You are all great
fox123 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC