View Full Version : Solved: What's the default RGB values in forms?
clhare
04-15-2005, 04:58 AM
I'm setting up a vba form that will change the background color of a frame if the user doesn't select something in it. If they go back and select something, I want to change the background color back to normal (gray), but I don't know what the values are for that and can't seem to get it right.
Can anyone help?
Thanks!
Cheryl:dunno
Killian
04-15-2005, 05:22 AM
Hi Cheryl,
Probably the best way to do this is to store the color value you want in a module level variable so you can use it when you switch back.
If you paste the code below into a new userform with a frame and a commandbutton, you'll see what I mean'declare in 'General declarations' so it's available to all the routines
Dim ORIGINAL_COLOR As Long
Private Sub UserForm_Initialize()
CommandButton1.Caption = "New color"
'capture frame's initial back color
ORIGINAL_COLOR = Frame1.BackColor
End Sub
Private Sub CommandButton1_Click()
If CommandButton1.Caption = "New color" Then
Frame1.BackColor = RGB(255, 0, 0)
CommandButton1.Caption = "Old color"
ElseIf CommandButton1.Caption = "Old color" Then
Frame1.BackColor = ORIGINAL_COLOR
CommandButton1.Caption = "New color"
End If
End Sub
clhare
04-15-2005, 06:15 AM
Awesome! It works perfectly!! Thank you so much!
Cheryl :clap:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.