PDA

Click to See Complete Forum and Search --> : problem with check1.value = 0 ....


razzaj
Dec 2nd, 1999, 06:05 AM
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 -

Aaron Young
Dec 2nd, 1999, 06:34 AM
Move your Click Event Code to the MouseUp Event, eg.

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
aarony@redwingsoftware.com
adyoung@win.bright.net

MartinLiss
Dec 2nd, 1999, 07:54 AM
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 formPrivate 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 followsPublic 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).]

razzaj
Dec 3rd, 1999, 03:27 AM
thanx guys ...it is working better now