|
-
Dec 2nd, 1999, 07:05 AM
#1
Thread Starter
Hyperactive Member
i am making a program that changes the value of a checkbox from 1 to 0 ... (the box is in form2 and the code to change it is in form1)
the code i am using is :
form2.check1(0).value = 0
the problem is that each time this line executes it calls the sub check1_click... this is annoying to me coz check1_click contains a lot of code i dont want to execute then .... any suggestions to bypas this undesirable "side effect " of the value change to 0 ???
- regards -
- razzaj -
-
Dec 2nd, 1999, 07:34 AM
#2
Move your Click Event Code to the MouseUp Event, eg.
Code:
Private Sub Check1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> vbLeftButton Then Exit Sub
'Place code from Click Event Here..
MsgBox "Click"
End Sub
Private Sub Command1_Click()
Check1 = Abs(1 - Check1)
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Dec 2nd, 1999, 08:54 AM
#3
I think there is a better way and that is through creation of a form Property. The advantage of a property is that you can update it without any unwanted side-effects, and read it whenever you want.
First add the following in the Declarations section of your form
Code:
Private m_intCBValue(2) As Integer ' This assumes you have 3 checkboxes
Then add a Property (which will have a Let which is used to update the value of the property, and a Get which is used to read the property) as follows
Code:
Public Property Get CheckBoxValue(ByVal intIndex As Integer) As Integer
CheckBoxValue = m_intCBValue(intIndex)
End Property
Public Property Let CheckBoxValue(ByVal intIndex As Integer, ByVal intValue As Integer)
m_intCBValue(intIndex) = intValue
End Property
Then when you you want to store the future value for check1(0), do CheckBoxValue(0) = vbChecked instead. By the way, I believe you should always use the vbChecked and vbUnChecked builtin constants instead of 0 and 1 since the constants are self-documenting. When you want to actually set the value of check1(0), then do Check1(0).Value = CheckBoxValue(0)
------------------
Marty
[This message has been edited by MartinLiss (edited 12-02-1999).]
-
Dec 3rd, 1999, 04:27 AM
#4
Thread Starter
Hyperactive Member
thanx guys ...it is working better now
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
|