Class Module Is Collection Of Other Class

May 24, 2006

I've created two modules, card and pack. Card has three variables (value, name, suit) and pack is made up of an array of 52 cards. Referencing it from a test module (NOT a class module) I expected to be able to use debug.print pack.card(32).suit to return the suit of the 32nd card. Instead I get an error message "Object or With variable not set". What am I doing wrong

Private p_strSuit As String
Private p_strName As String
Private p_iValue As Integer
Public Property Let Suit(strSuit As String)
p_strSuit = strSuit
End Property

Public Property Get Suit() As String
Suit = p_strSuit
End Property

Public Property Let Name(strName As String)
p_strName = strName
End Property......................................

View 7 Replies


ADVERTISEMENT

Class With Property As Collection Of Another Class

Nov 25, 2008

I've created a class called CStock. It has 5 standard properties (with Get/Let methods) as explained in that article above. Nothing fancy here.

I also want to create a CPortfolio class that has 3 properties: pName, pNumberofPositions, and pHoldings. the first 2 are stardard, but the last one is different. I want it to somehow keep a collection of stocks.

View 10 Replies View Related

Adding Objects To Collection Within Class?

Nov 15, 2013

Code:
Private garage_ As Collection
Public Property Get garage() As Collection: Set garage = garage_: End Property
Public Property Set garage(ByVal value As Collection): Set garage_ = value: End Property

[Code]...

I have the above piece of code within a "Person class" in order to add a vehicle to a person's garage. I was wondering if there is a better way to structure and/or execute this? (Perhaps not using a collection? or my adding to the collection directly?)

View 5 Replies View Related

Class Module

Feb 15, 2010

I would like to create a class module that it's the same as a connector shape (for example), but with additional custom properties defined by me. For example, I would like it to have a temperature property.

So, for example if I write in a Sub procedure:

Dim Test1 as EnhancedConnector
Set Test1 = New EnhancedConnector
A new connector appears in the activesheet, but this connector must have my custom defined properties available to VBA Code

View 9 Replies View Related

Purpose And Definition Of Class Module

Nov 23, 2008

What exactly is a Class Module? I've tried doing some searching on Google and haven't really found a straight answer as to what a class module is and what it is used for. How does it differ from a Normal Module?

View 2 Replies View Related

Sharing Class Module Among Multiple Userforms?

Apr 22, 2014

I have two user forms, each with a checkbox for Jan-Dec. Also, I have a checkbox "All" to check/uncheck the Jan-Dec boxes. I also created a class module so that if any of the Jan-Dec boxes get unchecked, while the "All" box is still checked, it will uncheck the All box. Basically I just don't want the All checkbox to be able to be checked while any single month is unchecked. The only/easiest way I found to do this was with a class module, so I would not need to create individual Checkbox_Jan_Click() events for each month.

Now my issue is, I have 2 userforms like this. I'd like them to share the same class module, but in the class module I need to refer to UserForm1.CheckBox_All. So I need to dynamically refer to whichever userform was active, but as far as I can tell, this is not possible.

View 4 Replies View Related

Creating A Class Module For Dbl Clicking Label

Jul 27, 2009

i would like to do is create a class module so that when the user double clicks on a label a msgbox will open saying the name of the double clicked label. If someone can get me to this point i can modify the code to suit my needs.

Some other things really quick though. I have 80 labels, but i only need this to work for labels 1 through 40 and the labels are on a multipage control within the userform.

View 5 Replies View Related

Call Public Function From Class Module

May 25, 2006

I have written a public function inside a class module. Is there anyway I could call the public function in Excel? What is the exact syntax to do it?

View 5 Replies View Related

Class Module Change Event For Controls

Nov 20, 2006

I have a class module (MyCtrlEvents) with a sub (TxtGroup_Change) which I want to handle on a change event for some specific textboxes.

When the form is opening I don't get the correct sum for the textbox "TBSum601". It should be 200 but I get 14464

When I then also change a number in the form for any control like "TB7%", the change trigger event doesn't seem to occur....

View 9 Replies View Related

Using Class Module For Handling Events Of Dynamically Created Controls

Mar 4, 2009

I have a userform with a single blank multipage. At runtime additional pages are added, the number of pages depends on input from another userform. Six frames, containing labels, textboxes and comboboxes are then added to each page.

I need to be able to use the textbox and combobox change events of these dynamically created controls to perform lookups and calculations. Although I can name the controls at the time they are created, it is not feasible to write code specifically for each control (I can have over 1,600 text boxes distributed over 9 pages, for example).

Having searched for some time on how to achieve this I believe using a class module is the way to go. However, how to use a class module is just not sinking in I'm afraid.

HTML Private WithEvents mpTextBox As MSForms.TextBox
Private WithEvents mpComboBox As MSForms.ComboBox

Private Sub Class_Initialize()
Set mpTextBox = MSForms.TextBox
Set mpComboBox = MSForms.ComboBox
End Sub

Private Sub mpComboBox_Change()
MsgBox "ComboBox value has been changed."
End Sub...........................................

View 2 Replies View Related

Class Modules: Class Object Can I Visually See It

Jul 23, 2009

i've reached a point where i would like to learn more about class modules but i have no resources. When i create a Class object can i visually see it? i want to know as i'm looking to use them within userforms if possible

View 4 Replies View Related

Class Modules?

Oct 14, 2008

I'm wondering about class modules and what they can be used for etc etc? i want to continue developing my VBA and feel that this area is the next step?

View 2 Replies View Related

Class As An AddIn

Jul 28, 2009

I have written a class that can be used as a replacement for Application.FileSearch in Excel 2007, that will take the same parameters etc. with no, or minimal code adjustments.

How do I now alter this so that it can be used as an AddIn by others?

I think that I have to remove all the sheets apart from 1 from the document, and save it as an .xla, but I am struggling with making this an addin, and then being able to use the addin from other code.

Does anyone have some instructions or a link to a website that could direct me? I have done a google search, but search for Excel, VBA, and classes (as well as AddIns), just gives lots of links to classes (as in teaching).

View 12 Replies View Related

Put A VBA Class Into Action?

May 28, 2014

JSON import to Excel - Stack Overflow

I understand most of what this post is saying, but I don't understand how to put it together in an excel module or class module.

View 5 Replies View Related

Instantiate A Class

Jun 30, 2007

i have created linked list class data structure. But how am i going to instantiate the linked list class. Excel VBA keep complaint me "Object variable or with block variable not set". Can somebody point out my mistake...

Dim theList As New LinkedList
Dim i As Integer
i = 0
Debug.Print theList.count

For i = 0 To 5 Step 1

theList.InsertNode "address", "date", i '"
Set p = p.pNext
Loop
Set p = Nothing
End Sub

Property Let free(setFree As Boolean)
Set temp = Nothing
Set Head = Nothing
Set First = Nothing
Set holdPrev = Nothing
End Property

View 9 Replies View Related

Class Of Permutations

Jul 23, 2007

I am creating a class of permutations. The problem is that there are many ways to describe what a permutation does. for example.

Dim aPerm As New clsPermutation
Dim bPerm As New clsPermutation
aPerm.DoesTranspose(2,3) : Rem aPerm.Action({a,b,c}) = {a,c,b}
MsgBox (aPerm Is aPerm.Inverse)

I want the message box to return True. But since aPerm and aPerm.Inverse are different instances of clsPermutaion, it returns False. (.Inverse is a read-only property that returns a clsPermutation.). What I would like to do is have a collection, myPermutations. When I specify the action that aPerm does, I would like

1) if nothing in myPermutations does the same thing as aPerm, then add aPerm to myPermutations.

2) if something (xPerm) does the same thing as aPerm, then

Set aPerm=xPerm
so that "xPerm Is aPerm" returns True.
The problem I have is that in the class module,.....................

View 8 Replies View Related

Determining Class Using Grades

Nov 25, 2013

I am trying to figure out a simple formula on determining class for students according to their achievement /grades. There are 9 classes altogether ( 7A, 7B, 7C, 7D, 7E, 7F, 7G, 7H and 7J). There are three columns for subject ( MATHS, ENGLISH, SCIENCE). So lets say the student get Grade A, A , A : The student will belong to Class 7A.

As attached.. TEST PSR.xls‎

View 2 Replies View Related

Check If Class Already Loaded / Set?

Apr 16, 2014

I am creating my first class and it will be possible for the Class Initialize event to fire twice.

Is there any way to check if the Class is already "loaded" .

View 11 Replies View Related

How To Set Class Object Properties

Jul 17, 2014

I have this textbox class which I want to show a userform when clicked and prevent manual input.

[Code] .....

I would expect that I could also set some object properties like color, width, height, locked etc. in the class module.

However I can't find how to (seen all corners of the internet). How do I set these properties?

View 10 Replies View Related

Calling Routine From A Class In Add-in?

Feb 4, 2014

I've got three workbooks that end users will be using for data entry. The VBA code for the three workbooks is identical.

I'm trying to encapsulate the code into an add-in so I only have one copy of the code that I have to debug/maintain.

Furthermore, I've also encapsulated the code in the add-in into a class. The class isn't really a "usual" object modelling some data; rather, it's a utility class processing Worksheet_Change and Worksheet_Activate events. Hopefully this isn't a really bad idea, rather than keeping the code in standard modules in the add-in.

The application is called "Midas". Here are some code excerpts:

Midas.xlam:

Standard Module:

[Code] ......

Class Module:

[Code] .....

And in the end user workbook:

[Code] .....

The Wbk_SheetChange event handler is triggering, but it's looking for the code in the end user workbook, instead of the class. Is there a way I can change

[Code] .....

to call the private routine "Cases_Changed" (where "Cases" is the sheetname) residing in the class instead of looking for it in the workbook?

View 4 Replies View Related

Sorted Data Class

Jan 8, 2010

Does anyone know of an Excel object class that you can put objects into with a key and the process it in key-sorted order? If not, is there a library that I can reference to get such a thing?

View 6 Replies View Related

IF Formula For Class Grades

Apr 16, 2013

I am attempting to create an IF or IF(AND formula that I can use to display the letter grade I earned based off of a certain percentage criteria.

"A" D11>=93%
"A-" D11>= 90%, D11=87%, D11=83%, D11=80%, D11=77%, D11=73%, D11=70%, D11=67%, D11=63%, D11=60%, D11

View 7 Replies View Related

VBA - Class Containing Label And Textbox

Nov 10, 2013

Possible to create a class that contains a textbox and a label?

I need something like a checkbox except instead of showing a check mark, it shows how many time the checkbox is clicked.

What I can think of is a combination of a textbox and a label. When the label is clicked, the number in the textbox increases (or decreases, depending on a pre-set condition) by one.

View 3 Replies View Related

Pass Array To A Class

Nov 29, 2007

I have a class

Private MemoryArray() As Variant

Private Sub Class_Initialize()
Redim MemoryArray(0) As Variant
End Sub

Public Sub ReplaceMemory(GivenArray() As Variant)
Redim MemoryArray(UBound(GivenArray)) As Variant

For Index = LBound(GivenArray) To UBound(GivenArray)
MemoryArray(Index) = GivenArray(Index)
Next Index
End Sub

that I am specificall passing an array to the replacememory sub. So in the program I have a global array doved criteria:

Dim Criteria() As String

Sub Product2()
'fill criteria with various entries
'do whatever in macro sub

Set MemoryCriteria = New Memory
MemoryCriteria.ReplaceMemory (Criteria)

and on the last line I get an error message:

Compile Error:
Type mismatch: array or user-defined type expected

View 9 Replies View Related

Create Class List From All Lists

Dec 16, 2013

I am creating a class list from a list of all students and classes. Names of students are in column A, their class name is in column B. In another sheet I would like to show a list of names from one particular class, say "Y8/En1".

Using a filter on the original list isn't an option as I will need it to pull/show other things eventually.

View 7 Replies View Related

Get The Match Property Of The Worksheetfunction Class

Dec 7, 2009

Unable to get the Match property of the worksheetfunction class? Here is my code

View 5 Replies View Related

Set XValues For Series Class (Chart)

Feb 5, 2010

I'm getting an error when I try to set the XValues for a chart in my excel worksheet. The chart shows up fine and the new series adds fine though when I try to set the XValues the below error occurs

'Unable to set the Xvalues property of the Series Class' 1004. My Code is below. Can anyone see anything wrong with it? This could be a floor in my understanding of the chart object. I don't want to be selecting charts and working on an activechart because I'll have several in the one worksheet.

View 2 Replies View Related

ClassFactory Cannot Supply Requested Class

Nov 29, 2011

I receive the following error whenever I try to run a macro in Excel: "System Error &H80040111 (-2147221231). classFactory cannot supply requested class." This is immediately followed by "Out of memory"

I was eventually able to stop the error from occurring by removing all forms containing a listview control in my macro file.

I have tried repairing my Office installation, uninstalling and reinstalling Office, and reregistering MSCOMCT2.OCX but nothing seems to work.

View 9 Replies View Related

Retrieve Class And Stakes From Data

Feb 10, 2013

Im wanting to get a function that can get the results I have in cols B and C from the data in col A .

I already have functions to get the 1400m and F1 as in cell A2 etc .

Sheet1  ABC1DataClassStakes2Mdn 3yo $6K 1400m F1Mdn 3yo$6K3OPN HCP C/WGT 1000 SOPN HCP C/WGT 4HCP $58K 1110m GHCP$58K5GRAZIA STYLE $177K 1100m GGRAZIA STYLE$177K60 - 91 $80K 1200m G0 - 91$80K7Rating 70 SW+P $10K 1400m G3Rating 70 SW+P$10K8MDN 2YO C/WGT 450 DMDN 2YO C/WGT 9OPN HCP $100K 1400m H10OPN HCP$100K10Mdn & JMP HWT $6K 2100m G2Mdn & JMP HWT$6K

View 2 Replies View Related

Method Of Range Class Failed

Aug 29, 2002

i just figured out that when you change sheets too often in VBA and get an "Activate Method Of Range Class Failed" or a "Select Method Of Range Class Failed" etc, simply retype the sheets command before it

for example :

Sheets("Work1").Select
Range("A1:D50").Select

OR

Sheets(Work1").Range("A1:D50").Select

this code in VBA, if used too often or the mentioned sheet is not the currently selected sheet in a Sub, will cause errors, and to correct this, simply type

Sheets("Work1").Select
Sheets("Work1").Range("A1:D50").Select

this makes sure that the sheet is selected before running any other range/sheet type commands.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved