Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems returning Collection object


I get this error:
Compile error

Argument not optional

when i try to return a collection like this:

For i = 1 To assyNums.count
For j = 1 To assyNums.Item(i).getBOM.count
partnum = assyNums.Item(i).getBOM.Item(j)
occur = numOccurances(partnum)
numOccur.Add (occur)
Next j
.......

(BOMParts is an obj variable and is already initialized)
Public Function getBOM() As Collection
getBOM = BOMparts
End Function


I have tried the simple way where I make a temporary collection an
assign it to what ".getBOM()" returns but same error. Any help

--
McManCS
-----------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...fo&userid=2437
View this thread: http://www.excelforum.com/showthread.php?threadid=39422

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Problems returning Collection object

M,

It is difficult to understand what you are trying to do.
Please show your variable declarations and describe
what the code is supposed to do.

Jim Cone
San Francisco, USA


"McManCSU"

wrote in message
...

I get this error:
Compile error

Argument not optional

when i try to return a collection like this:

For i = 1 To assyNums.count
For j = 1 To assyNums.Item(i).getBOM.count
partnum = assyNums.Item(i).getBOM.Item(j)
occur = numOccurances(partnum)
numOccur.Add (occur)
Next j
.......

(BOMParts is an obj variable and is already initialized)
Public Function getBOM() As Collection
getBOM = BOMparts
End Function


I have tried the simple way where I make a temporary collection and
assign it to what ".getBOM()" returns but same error. Any help?


--
McManCSU
------------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...o&userid=24379
View this thread: http://www.excelforum.com/showthread...hreadid=394222

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems returning Collection object


All I am trying to do is step through a collection which I have in a
object. So I want is to do a 'get function' to get the collection
store it into a temp variable, and then do a "for each... " But fo
some reason if gives that error and points to where I assign tempBO
the collection.


Code
-------------------
Private Sub setupTFIDF()
Dim partnum As String
Dim occur As Integer
Dim numOccur As New Collection
Dim tempBOM As New Collection
Dim assy As New Assembly
Dim comp As New Component

For Each assy In assyNums
tempBOM = assy.getBOM()
For Each comp In tempBOM
partnum = comp.getAssy()
occur = numOccurances(partnum)
numOccur.Add (occur)
Next comp
'Calc TFIDF by sending number of boards and occurance list
assy.determineTFIDF numBoards, numOccur
Next assy
End Su
-------------------


and using this "Assembly" object:


Code
-------------------
Private BOMparts As New Collection
.......
.......
Public Function getBOM() As Collection
getBOM = BOMparts
End Functio
-------------------

--
McManCS
-----------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...fo&userid=2437
View this thread: http://www.excelforum.com/showthread.php?threadid=39422

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems returning Collection object


Ok, i narrowed it down:

Dim x As New Collection
Dim y As New Collection
x = y

it errors with that same error on 'x=y'

why and how can i fix it

--
McManCS
-----------------------------------------------------------------------
McManCSU's Profile: http://www.excelforum.com/member.php...fo&userid=2437
View this thread: http://www.excelforum.com/showthread.php?threadid=39422

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Problems returning Collection object

M,

You may want to review:
Don't Use The New Keyword In A Dim Statement
http://www.cpearson.com/excel/variables.htm

The following doesn't throw an error,
but how you would use it is a puzzle to me.
'-------------------
Dim x As New Collection
Dim y As New Collection
Set x = y

'Do stuff

Set x = Nothing
Set y = Nothing
'------------------
Jim Cone
San Francisco, USA


"McManCSU"

wrote in message
...

Ok, i narrowed it down:

Dim x As New Collection
Dim y As New Collection
x = y
it errors with that same error on 'x=y'
why and how can i fix it?
--
McManCSU



Reply
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
Collection Object Keys Todd Huttenstine Excel Programming 10 October 29th 04 01:14 PM
returning pivottable object from a range object Grant Excel Programming 2 September 27th 04 02:22 AM
Function unable to return Collection object Adrian[_7_] Excel Programming 1 July 12th 04 06:22 PM
Collection Class problems Flemming Dahl Excel Programming 4 February 11th 04 04:41 PM
CombBox - Object of What Collection? George Excel Programming 7 February 10th 04 12:01 AM


All times are GMT +1. The time now is 10:30 AM.

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"