View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Carim[_2_] Carim[_2_] is offline
external usenet poster
 
Posts: 97
Default CommandButton not responding

On Jan 11, 11:47*pm, "Peter T" <peter_t@discussions wrote:
You haven't given any information that helps others to suggest what you
might have done wrong.

Have a go with the following, an empty userform and a class named
clsBtnEvnts. Run the form and check events in all 20 buttons respond.

'''' code in class named 'clsBtnEvnts'

Public WithEvents btn As MSForms.CommandButton
Public id As Long

Private Sub btn_Click()
* * btn.BackColor = Int(Rnd() * vbWhite)

* * *btn.Parent.Caption = btn.Caption & " * ID : " & id
* * If id = 20 Then
* * * * MsgBox "Bye"
* * * * Unload btn.Parent
* * End If

End Sub

'''' end code in class

Option Explicit
Private arrClsBtn(1 To 20) As clsBtnEvnts

Private Sub UserForm_Initialize()
Dim i As Long, r As Long, c As Long
Dim cb As MSForms.CommandButton
Const cGAP As Single = 3, cHT As Long = 18, cWD As Long = 66

* * For r = 0 To 4
* * * * For c = 0 To 3
* * * * * * i = i + 1
* * * * * * Set arrClsBtn(i) = New clsBtnEvnts
* * * * * * Set arrClsBtn(i).btn = Me.Controls.Add("Forms.CommandButton.1")
* * * * * * arrClsBtn(i).id = i
* * * * * * With arrClsBtn(i).btn
* * * * * * * * .Left = cGAP + c * (cWD + cGAP)
* * * * * * * * .Top = cGAP + r * (cHT + cGAP)
* * * * * * * * .Width = cWD
* * * * * * * * .Height = cHT
* * * * * * * * .Visible = True
* * * * * * * * If i = 20 Then
* * * * * * * * * * .Caption = "Close"
* * * * * * * * Else
* * * * * * * * * * .Caption = "btn - " & Chr(64 + i)
* * * * * * * * End If
* * * * * * End With

* * * * Next
* * Next

End Sub

Regards,
Peter T

"Carim" wrote in message

...
On Jan 11, 3:06 pm, "Peter T" <peter_t@discussions wrote:





Hello again Carim,
<snip


I found a solution : include two additional Locked CommandButtons
( lower and upper bounds ) when building the group ...
for the Class module to recognize all the 20 Buttons in-between !!!
Do not ask me why it is working ..., I suspect the couple Excel 2000
SR1 with XP has not yet solved all of their ActiveX controls handlings
...


The reason your code was not working correctly before is because you had
done something wrong. It is not possible to suggest what you did wrong
because you have not given the details Rick asked you for, two times.


Although you may have fixed it, for now, I am sure the reason is not due
to
what you say you suspect.


Regards,
Peter T


Hi Peter,

Sorry but I I gave the details Rick asked for ...
1. One Button out of a sequence of 20 Buttons is not responding ...
2. The Code has not been changed ... and working with a Class, all 20
Buttons call
the very same code in the unique class ...
Very honestly, I wish I could understand what I have done wrong ...
cause it is important to keep on progressing ...
I trust you when you say " *I am sure the reason is not due to
what you say you suspect ... "
What would be your best guess ... ?
Regards- Hide quoted text -

- Show quoted text -


Peter,

I could not agree more ...
Your code is working fine ...
What I am after since the very beginning is :
"What is it that I have done wrong ... which prevents only ONE button
out of 20 not to respond ...?"
At least, we both agree it has nothing to do with the code itself ...
since it is common to the 20 Buttons ...
So , in your opinion, What could that be ...?
Cheers