|
Visual Basic (VB and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Please read the DISCLAIMER.
Here is an INDEX to all the procedures.
You will probably need one copy of my GLOBAL DECLARATIONS.
Public Function cmdColoursClick(frmMe As UserForm)
' Procedure : cmd_ColoursClick
' Description: Change the colors on all buttons to a new standard combination.
' Copyright: Chris Greaves Inc.
' Inputs: A Word97 GUI form.
' Returns: None.
' Assumes: None.
' Side Effects: None.
' Tested: By a call from the user.
' Re-seed the randomizer (probably from the system clock)
Randomize
Dim strColours As String ' Will accumulate a new string of colours. See cmd_UserFormInitialize
' We start with a null, the delimiter character, the base (usually 256) and another delimiter.
strColours = str(0) & strcINIFileDelimiter & str(intcBase) & strcINIFileDelimiter
' Values for Background Colour Red (Blue and Green)
Dim intBCR As Integer, intBCB As Integer, intBCG As Integer
' Background RED code
While InStr(strColours, str(intBCR)) ' loop until a unique colour is made.
intBCR = Rnd * intcBase ' generate a fresh colour.
Wend
strColours = strColours & str(intBCR) & strcINIFileDelimiter ' append to colours string
' Background BLUE code
While InStr(strColours, str(intBCB)) ' loop until a unique colour is made.
intBCB = Rnd * intcBase ' generate a fresh colour.
Wend
strColours = strColours & str(intBCB) & strcINIFileDelimiter ' append to colours string
' Background GREEN code
While InStr(strColours, str(intBCG)) ' loop until a unique colour is made.
intBCG = Rnd * intcBase ' generate a fresh colour.
Wend
strColours = strColours & str(intBCG) & strcINIFileDelimiter ' append to colours string
' Values for Foreground Colour Red (Blue and Green)
Dim intFCR As Integer, intFCB As Integer, intFCG As Integer
' Foreground RED code
intFCR = Rnd * intcBase ' generate a fresh colour.
strColours = strColours & str(intFCR) & strcINIFileDelimiter ' append to colours string
' Foreground BLUE code
intFCB = Rnd * intcBase ' generate a fresh colour.
strColours = strColours & str(intFCB) & strcINIFileDelimiter ' append to colours string
' Foreground GREEN code
intFCG = Rnd * intcBase ' generate a fresh colour.
strColours = strColours & str(intFCG) & strcINIFileDelimiter ' append to colours string
' Now make use of the colours to set the Background and Foreground colours.
Dim myControl As Control
For Each myControl In frmMe.Controls
On Error Resume Next
myControl.BackColor = RGB(intBCR, intBCB, intBCG)
On Error Resume Next
myControl.ForeColor = RGB(intFCR, intFCB, intFCG)
Next myControl
' Values for Background Screen Red (Blue and Green)
Dim intBSR As Integer, intBSB As Integer, intBSG As Integer
While InStr(strColours, str(intBSR)) ' loop until a unique colour is made.
intBSR = Rnd * intcBase ' generate a fresh colour.
Wend
strColours = strColours & str(intBSR) & strcINIFileDelimiter ' append to colours string
While InStr(strColours, str(intBSB)) ' loop until a unique colour is made.
intBSB = Rnd * intcBase ' generate a fresh colour.
Wend
strColours = strColours & str(intBSB) & strcINIFileDelimiter ' append to colours string
While InStr(strColours, str(intBSG)) ' loop until a unique colour is made.
intBSG = Rnd * intcBase ' generate a fresh colour.
Wend
strColours = strColours & str(intBSG) & strcINIFileDelimiter ' append to colours string
' Now make use of the colours to set the Form colours.
frmMe.BackColor = RGB(intBSR, intBSB, intBSG)
' Preserve these settings in the application INI file
Call strPPA(strcColours, strColours)
' We no longer trace/log the colour change
' Call ERL("0013", intcErrorInform, strColours)
' I don't know why I repaint at this point.
frmMe.Repaint
End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Thursday, November 15, 2001 |