Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default subs or functions with user defined types

I've been trying to call a subroutine where the parameters include a user
defined type without success.
Pseudo-code of what I'm trying to do is as follows:

type typArr
key as long: dat as string
end type
dim arr() as typArr
Sub main()
dim point as long
point=add (this, arr(), arr().key)
arr(point).dat= ..... (to finish adding other data items)
end sub
function add( This as variant, ToThis() as ???, Key as ???) as long
( find where to insert and return location, includes shifting data in
ToThis() )
redim preserve tothis(1 to newcount) (if need more arr())
end function

How do I do this? (I eventually want to make the add() function as part of a
class)




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default subs or functions with user defined types

I think this is causing the problem:
arr().key

You can pass the entire array across, but you can't have 'arr().key'

Try something like:

point = add("something", 123, arr())

with

Function add(this As Variant, aKey As Long, toThis() As typArr) As Long


HTH

Tim

"Ray Pixley" wrote in message
news:oG1Mf.772$FE2.347@trnddc01...
I've been trying to call a subroutine where the parameters include a user
defined type without success.
Pseudo-code of what I'm trying to do is as follows:

type typArr
key as long: dat as string
end type
dim arr() as typArr
Sub main()
dim point as long
point=add (this, arr(), arr().key)
arr(point).dat= ..... (to finish adding other data items)
end sub
function add( This as variant, ToThis() as ???, Key as ???) as long
( find where to insert and return location, includes shifting data in
ToThis() )
redim preserve tothis(1 to newcount) (if need more arr())
end function

How do I do this? (I eventually want to make the add() function as part of

a
class)






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default subs or functions with user defined types

Close and thoughtful, but I may have oversimplified what I want to do. I
should have used "Insert" instead of "Add" as a subroutine name (symantics).
But the other problem is I'd like to use the same subroutine with other
typArrs that have a different data structure, but have at least a "key"
member, so as to reduce the amount of nearly duplicate code that I'm dealing
with. Also, the key may not always be a long, it may be a string, and I'd
like the option of mindlessly using either type just in that subroutine call
without having to disable Option Explicit.

"Tim Barlow" wrote in message
...
I think this is causing the problem:
arr().key

You can pass the entire array across, but you can't have 'arr().key' Try
something like:

point = add("something", 123, arr()) with
Function add(this As Variant, aKey As Long, toThis() As typArr) As Long

HTH

Tim

"Ray Pixley" wrote in message
news:oG1Mf.772$FE2.347@trnddc01...
I've been trying to call a subroutine where the parameters include a user
defined type without success.
Pseudo-code of what I'm trying to do is as follows:

type typArr
key as long: dat as string
end type
dim arr() as typArr
Sub main()
dim point as long
point=add (this, arr(), arr().key)
arr(point).dat= ..... (to finish adding other data items)
end sub
function add( This as variant, ToThis() as ???, Key as ???) as long
( find where to insert and return location, includes shifting data in
ToThis() )
redim preserve tothis(1 to newcount) (if need more arr())
end function

How do I do this? (I eventually want to make the add() function as part
of

a
class)








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
Standard chart types over-ridden by user-defined 'default' SWRDA man Charts and Charting in Excel 1 November 3rd 08 12:12 AM
Save user-defined chart types in a shared Excel template? graphicslady Charts and Charting in Excel 7 September 7th 06 02:07 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
Unable to add user-defined data types to a collection Adrian[_7_] Excel Programming 3 July 14th 04 08:01 PM


All times are GMT +1. The time now is 08:09 PM.

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

About Us

"It's about Microsoft Excel"