Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I found the following code on this webpage:
http://www.office-loesung.de/ftopic220336_0_0_asc.php
VB
Public WithEvents cmdCommandButton As CommandButton
Option Explicit

Dim CommandButtons(15) As clsCommandButtons

Private Sub UserForm_Initialize()
Dim zaehler As Long
For zaehler = 0 To 15
    Set CommandButtons(zaehler) = New clsCommandButtons
    Set CommandButtons(zaehler).cmdCommandButton = Me.Controls(zaehler)
Next
End Sub
Private Sub UserForm_Terminate()
Dim zaehler As Long
For zaehler = 0 To 15
    Set CommandButtons(zaehler) = Nothing
Next
End Sub

First I changed parts of the code and it didn´t work, I got the following Message:
Compile error: User-defined type not defined

So I used the originial code and tried it again and I got the same mistake. Is something wrong with the code?


Edit:
It works after putting the first line in a extra class, named clsCommandButtons. Unfortunaly it's not clearly in the text of the webpage
Posted
Updated 14-Jul-15 19:52pm
v2

1 solution

Most likely you haven't copied the whole example. The code uses a class named clsCommandButtons over here
VB
Dim CommandButtons(15) As clsCommandButtons

But if you haven't included definition for that class in your project, compile will fail.

So have a look at the source code again and check if the definition exists. Note that it may be in a separate module.
 
Share this answer
 
Comments
Chi Ller 14-Jul-15 4:01am    
There`s no definition for clsCommandButtons on the page and nowhere is a mark how or where or that you have to define the class
Wendelius 14-Jul-15 4:15am    
Then it sounds like a bug... I'm sorry but I can't help you much further... If possible, try contacting the author of the project.
Chi Ller 14-Jul-15 5:01am    
Well i will search for another way. How can I delete the question?
Wendelius 14-Jul-15 5:18am    
There's no need to delete the question. Perhaps someone will see it who knows that exact project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900