Problem with Array inside a Class Module

scottyleics

New Member
Joined
Dec 2, 2011
Messages
3
Hi,

I have tried for a couple of hours searching and trying to get this work. I am pretty sure its an easy problem as well but I just cannot seem to work it out.
Sorry if its trivial or has been covered before.

This my class module: (clsUsers)

Option Explicit

Public UserName As String
Public UserAge As Integer
Public UserAtrr() As Boolean
Public UserHeight As Integer

and a sub in a userform:
Dim UserInfos(100) As clsUsers ' global
UserInfos(a).UserName = txtUserName

etc etc.
I need to be able to have "Public UserAtrr() As Boolean" as an array with 15 elmemnts to be addressed like:
UserInfos(a).UserAttr(0) etc

Of course it doesnt allow this as you cannot have an array delcared like this.

Any ideas? I really am stuck.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
If you create a class, you access its properties via Let, Get, and Set procedures in the class, and implement its methods as Subs within the class.

Maybe just creating a user-defined data type would be more in line with what you're trying to do.
 
Upvote 0
If you do want a class, then you need something like this in the class:
Code:
Private mUserAttr(1 To 15) As Boolean

Public Property Get UserAttr(n As Long) As Boolean
    usersttr = mUserAttr(n)
End Property
Public Property Let UserAttr(n As Long, bln As Boolean)
    mUserAttr(n) = bln
End Property
 
Upvote 0
We'll never know, rory ...
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

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