Results 1 to 1 of 1
2001-02-28, 11:03 #1
- Join Date
- Feb 2001
- Yilgarn region of Toronto, Ontario
- Thanked 0 Times in 0 Posts
Code: frmHeader - changing the captions
Here's the last post (for now) on the basic form.
here we have the click event for the "captions" button on your form - same procedure as before - double-click on the "captions" button in the form design window in VBE, then set the VBA code in your frmHeader module to look like this:
<pre>Private Sub cmdCaptions_Click()
The procedure cmd_CaptionsClick can be defined in a regular code module in your template - I dropped mine into the module U. This module is mainly a collection of hard-wired slogans I've accumulated over the ages. because it is large I've essayed with attaching it as a file to this post. Below I reproduce the head and tail of it, with the bulk of the data code missing.
The idea behind the Captions Click event was to demonstrate that captions could be changed on the fly. I chose to load the help captions with humorous sayings, in real life I'd be switching the language from English to French to Spanish etc.
If you want to put real help on your form controls BEFORE you start, go into the GUI form, select (click) a control such as the OK button, choose View Properties, and load the ControlTipText field with an appropriate string ("This will save settings and terminate the application").
<pre>Public Sub cmd_CaptionsClick(frmMe As UserForm)
' Change the balloon text on all buttons
Const intcCaptions As Integer = 109 ' hard code this as new captions are added.
Dim strCaptions(intcCaptions) As String ' array to store all these hardcoded captions.
strCaptions(0) = "Do not walk behind me, for I may not lead._
Do not walk ahead of me, for I may not follow. _
Do not walk beside me, either. Just leave me the hell alone."
strCaptions(1) = "The journey of a thousand miles begins with _
a broken fan belt and leaky tire."
strCaptions(109) = "Lord, help me slow downandnotrushthroughwhatIdo"
Dim myControl As Control
Dim intControl As Integer
intControl = intcCaptions * Rnd()
For Each myControl In frmMe.Controls
If intControl >= intcCaptions Then intControl = 0
myControl.ControlTipText = strCaptions(intControl)
intControl = intControl + 1