In DetailWindow I created a control set Label1 for Label1. In one of the functions I instantiate DetailWindow with Dim NewWindow as new DetailWindow
. Now I want to address the Label1 Control Set from this function. How can I do that? Is the Control Set a dynamic array? NewWindow.Label1(0).text=“test” works well. However NewWindow.Label1(1).text=“test” generates a runtime error. Do you have to append a new element to the control set (something like NewWindow.Label1.Append
?). But what do you have to append? I really don’t see how I can use this control set…
You would use
Dim l As New Label1
l.top = label1(0).top + label1(0).height + 12
l.text = "test"
A control set is not an array in that you can remove an item from the middle of the set without renumbering the rest and therefore ubound doesn’t work either - you need to keep a reference to the upper limit.
HTH
Wayne
Wayne, thank you. This piece of code generates an error on the first line “There is no class with this name
” (Label1). Also the second and third line generates errors. I really don’t understand control sets. Even the documentation gives no real answer how to use them…
You will need to prefix Label1 with DetailWindow.
Dim l As New DetailWindow.Label1
l.top = DetailWindow.label1(0).top + DetailWindow.label1(0).height + 12
l.text = "test"
“This type is private, and can only be used within its module
”. This is the error on line 1 referring to Label1. I try to use the control set Label1 (created in DetailWindow) from a function CreateLabels()
where I instantiate DetailWindow to NewWindow. I get the same error when I refer tot NewWindow.Label1
.
I changed the code a little bit: in DetailWindow I created public property MyLabels() As Label
. In the function CreateLabels() (where I instantiate NewWindow from DetailWindow) I used the following code:
NewWindow.MyLabels.Append(New Label)
NewWindow.MyLabels(0).Text="test"
NewWindow.MyLabels(0).Left=100
NewWindow.MyLabels(0).Top=300
NewWindow.MyLabels(0).Enabled=TRUE
NewWindow.MyLabels(0).Visible=True
No errors during compilation. But, no result on the screen! May be I am too tired to see the problem?
Did you have a look at the project I linked to?
Wayne, yes I did. And your project works. But, I have to reorganize my project to do this, because all my methods are in Modules outside DetailWindow. I will try to reorganize the project tomorrow since here (in Belgium) it is about 10:00 PM on Wednesday. Thank you very much for your help. I will inform you tomorrow!
Wayne, It’s late in the evening But I couldn’t wait to test your solution. I commented out some lines in my project and inserted your solution to the problem. And now, it works!!! Thank you very much for your help and have a nice day in beautiful New Zealand!
Sleep well!
Wayne, thank you! I was having the same problem as Carlos. After downloading your sample project, it all made sense.
Thanks - Keir