- Local time
- Today, 09:23
- Joined
- Jul 9, 2003
- Messages
- 16,243
Finding the Caption of a Label
By way of an example, I utilize the Controls Collection to find a Control's caption in my CallCalled Class Module:-
https://www.niftyaccess.com/callcalled-class-module/
There are two functions in the Class module at the bottom of the page:-
fHasLabel which checks to see if the control actually has a label. It does this by looking at all the labels on the form, finds the labels "parent name", (always a control) then checks to see if it matches the control name passed in. This is an excellent method you can use to check the existence of something, looking for its "text" name because this does not cause a crash, if you try and actually look for a control directly, if it does not exist then you get an error. So doing it this way avoids generating Errors.
And then the function fGetLabel utilizes the function fHasLabel to make sure that control actually has a label. If you try and access the label caption of a label that does not exist, then the code will fail. fGetLabel returns the caption by accessing the controls personal? local? Collection, always Control (0) Zero.....
Sent from my Pixel 3a using Tapatalk
Last edited: