|
-
Feb 9th, 2012, 11:56 AM
#1
[RESOLVED] Use a control property like a form property
I want to enable/disable a command button depending on a combination of selections of various controls: a few groups of radio buttons, a number of checkboxes and others.
The cumbersome inelegant way is to check the state of all those controls whenever any of them is changed. A very convenient way to deal with this when it's a variable that must change its value, is to make it into a form property that tests the control state in its Let procedure. Is there a similar approach for a control's property?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Feb 9th, 2012, 12:04 PM
#2
Re: Use a control property like a form property
Radio buttons and checkboxes share a True/False Value property.
What are the "and others"? Do they have a Value property as well?
If not, then you would need a separate procedure that tested whatever property they have that needs to be evaluated.
-
Feb 9th, 2012, 12:27 PM
#3
Re: Use a control property like a form property
Not exactly of the problem; a bit confused.
You can create a variable that holds up to 30 on/off or true/false values by using the bits.
For example.... Let's say there are 5 controls that determine the state and we'll call the variable m_ButtonState & declared as Long
- Control 1 when checked/clicked toggles bit 1: m_ButtonState = m_ButtonState Xor 1
- Control 2 when checked/clicked toggles bit 2: m_ButtonState = m_ButtonState Xor 2
- Control 3 when checked/clicked toggles bit 3: m_ButtonState = m_ButtonState Xor 4
- Control 4 when checked/clicked toggles bit 4: m_ButtonState = m_ButtonState Xor 8
- Control 5 when checked/clicked toggles bit 5: m_ButtonState = m_ButtonState Xor 16
Now if all bits must be set to enable the button:
If m_ButtonState = 31 Then ... ' (1,2,4,8,16 Or'd together)
If only bits 2 and 5 must be set, then
If m_ButtonState = 18 Then ... ' (2,16 Or'd together)
Does this make sense?
-
Feb 9th, 2012, 03:40 PM
#4
Re: Use a control property like a form property
 Originally Posted by LaVolpe
Not exactly of the problem; a bit confused.
...
You may be confused because I was confusing.
As a matter of fact I think I was mixing up different situations. Probably I should have gone out and taken some fresh air before posting.
What I had in mind was a form's property that has loads of code to be run when it changes, and the value can be changed anywhere in the entire project. So the code is 'centralized' and you don't have to worry as the property sub fires automatically any time the value changes.
This case is different: what I was aiming for was some sort of a similar subroutine that would be automatically triggered whenever any of the controls received an event. I think all I have to do is add a call to a subroutine at the end of the event handlers of those controls, and place the necessary statements in it, for example your suggested code.
So, my apologies for the confusion -I was the first to be confused- and thanks for your answer.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|