LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Collection Code

I created a collection based on the code in the thread titled "Class Instance
Identifier". On my Sheet1 I have a command button CommandButtonMainAddaModel
that starts a UserForm UserForm1. UserForm1 has a textbox TextBox1 and two
command buttons CommandButtonAddModel and CommandButtonCancelAddModel. The
CommandButtonAddModel calls AddModeltoCollection from Module1.

Sub AddModeltoCollection()

Dim clsVar As Class1

Set clsVar = New Class1
clsVar.Model = UserForm1.TextBox1.Value
StoreObject clsVar, clsVar.Model

End Sub

Sub StoreObject(cObject As Class1, sName As String)

If modelClass Is Nothing Then
Set modelClass = New Collection
End If

modelClass.Add cObject, sName
End Sub

Class1 has several properties including Model which is the key property.

I am trying to display the list of Model key names in a listbox in a new
form called UserFormModelListDisplay. Thread titled Object Required Error
8/22/05 is related to my problem. I have a type mismatch in the following
code trying to AddItem the Model properties to the ListBox1. See the
following code. Also it appears that the collection is lost when UserForm1
is unloaded. This may or may not be the case as I have not been able to
successfully list the property.

Private Sub UserFormModelListDisplay_Initialize()

Dim mItem As Variant

Load UserFormModelListDisplay
For Each mItem In modelClass
UserFormModelListDisplay.ListBox1.AddItem mItem
Next mItem
UserFormModelListDisplay.Show

End Sub

Any help here would be greatly appreciated.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
data collection driller Excel Discussion (Misc queries) 1 October 13th 09 01:04 AM
code to add a name to the names collection and assign a reference keithb Excel Programming 2 August 5th 05 06:38 AM
Collection Todd Huttenstine Excel Programming 4 December 17th 04 09:41 PM
Collection Variable Todd Huttenstine Excel Programming 4 August 14th 04 05:32 PM
sheet collection Tom Ogilvy Excel Programming 0 October 28th 03 03:15 PM


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"