Thread: array of labels
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Wiley Post Wiley Post is offline
external usenet poster
 
Posts: 3
Default array of labels

I want to modify a UserForm dynamically by adding some number of labels from
my VB/Excel program:
Dim labels() as MSForms.Label
:
ReDim labels(NumLabels)

At this point I have an array of Labels with each value set to Nothing. If
I do this:

Set labels(0) = New MSForms.Label
I get runtime "Invalid use of New keyword" and Help says I cannot reference
a class name in this context -- I need to reference a specific object name,
e.g. Label1. So I tried:

Dim Label1 as MSForms.Label
Set labels(0) = New Label1

and I get "User-defined type not defined"

I have tried other things such as
Dim labels() as New MSForms.Label
and I also get errors.

How do I programmatically create an array of Labels so that I can place them
on my UserForm?