Class Procedure with multiple arguments

bigt95nt

New Member
Joined
Apr 11, 2011
Messages
26
I have defined a let procedure that initalizes all the varriables in the class. No Problem. However; when i try to use this procedure i continue to get syntax errors! Is there a limit to the # of varriables you can pass to an instance of a class? Given the following definition what would be the correct syntax when refering to the procedure.

<CLASS Legend legend<CLASS named>
Private X As Integer
Private Y As Integer
Private Width As Integer
Private Heigth As Integer
Private Count As Integer
Private Color() As Long
Private Text() As String
Private FontSize2() As Integer
Private Visible() As Boolean
Public Property Let InitLegend(iIndex As Integer, _
iX As Integer, _
iY As Integer, _
iWidth As Integer, _
iHeigth As Integer)
Count = iIndex
X = iX
Y = iY
Width = iWidth
Height = iHeight
ReDim Preserve Color(1 To iIndex)
ReDim Preserve Text(1 To iIndex)
ReDim Preserve FontSize2(1 To iIndex)
ReDim Preserve Visible(1 To iIndex)
End Property

<END p class<>
Sub test()
dim tst as new legend

tst.initLegend(count,x,y,width,height)'THIS DOESENT WORK:confused:

Please comment
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
You can only set one property at a time.

I expect that property could be a user-defined type (declared as public in a code module), and a variable of that type is passed as the propery value, but have never tried.

Or you could have separate count, x, y, width, and height properties.
 
Upvote 0
The syntax for setting (letting) a property of an object is
Code:
myObject.Property = Value
your routine doesn't see to fit that mold.

It seems like InitLegend is more like a method than a property. Try
Code:
Public Sub InitLegend(iIndex As Integer, _
                              iX As Integer, _
                              iY As Integer, _
                              iWidth As Integer, _
                              iHeigth As Integer)
    Count = iIndex
    X = iX
    Y = iY
    Width = iWidth
    Height = iHeight
    ReDim Preserve Color(1 To iIndex)
    ReDim Preserve Text(1 To iIndex)
    ReDim Preserve FontSize2(1 To iIndex)
    ReDim Preserve Visible(1 To iIndex)
End Sub
Code:
Sub Test()
    dim tst as new legend

    tst.initLegend 5, 4, 3, 2, 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,862
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top