Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default templated array as function parameters

Hello, I am writing some code to test whether an array is undefined (See
code below). I am passing an array of integers to the function right now,
and I am wondering if i can extend this so that it can be apply to array of
any type (even user defined type). Something like a function template.




Public Function isUndefArray(ByRef a() As integer) As Boolean
Dim l As Long
On Error Resume Next
l = UBound(a)
If Err.Number = 9 Then
Debug.Print Err.Description

isUndefArray = True
Exit Function
End If
isUndefArray = False
End Function


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default templated array as function parameters

I think this will work for any type of array:

''Returns True is the passed array has been dimensioned else False
Function ArrayDimmed(vntArray As Variant) As Boolean
On Error Resume Next
ArrayDimmed = IsNumeric(UBound(vntArray))
End Function


--
Jim Rech
Excel MVP
"Steven Deng" wrote in message
news:99cid.107442$%k.6341@pd7tw2no...
| Hello, I am writing some code to test whether an array is undefined (See
| code below). I am passing an array of integers to the function right now,
| and I am wondering if i can extend this so that it can be apply to array
of
| any type (even user defined type). Something like a function template.
|
|
|
|
| Public Function isUndefArray(ByRef a() As integer) As Boolean
| Dim l As Long
| On Error Resume Next
| l = UBound(a)
| If Err.Number = 9 Then
| Debug.Print Err.Description
|
| isUndefArray = True
| Exit Function
| End If
| isUndefArray = False
| End Function
|
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default templated array as function parameters

Thanks Jim. i tried but it is not working with user defined types

Sincerely,
Steven Deng


"Jim Rech" дÈëÏûÏ¢ÐÂÎÅ
...
I think this will work for any type of array:

''Returns True is the passed array has been dimensioned else False
Function ArrayDimmed(vntArray As Variant) As Boolean
On Error Resume Next
ArrayDimmed = IsNumeric(UBound(vntArray))
End Function


--
Jim Rech
Excel MVP
"Steven Deng" wrote in message
news:99cid.107442$%k.6341@pd7tw2no...
| Hello, I am writing some code to test whether an array is undefined

(See
| code below). I am passing an array of integers to the function right

now,
| and I am wondering if i can extend this so that it can be apply to

array
of
| any type (even user defined type). Something like a function template.
|
|
|
|
| Public Function isUndefArray(ByRef a() As integer) As Boolean
| Dim l As Long
| On Error Resume Next
| l = UBound(a)
| If Err.Number = 9 Then
| Debug.Print Err.Description
|
| isUndefArray = True
| Exit Function
| End If
| isUndefArray = False
| End Function
|
|




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
templated hiring questions for new employees Templated Questions to ask potiential em Excel Discussion (Misc queries) 1 February 14th 07 10:16 PM
default save directory for a templated worksheet Mike Lang New Users to Excel 2 September 8th 06 11:08 PM
MSNStockQuote Function Parameters Bobtarrel Excel Worksheet Functions 2 July 17th 05 02:36 PM
Function Parameters Paddyk Setting up and Configuration of Excel 2 April 12th 05 08:52 AM
Implement CSE function through VBA with parameters Bastanu Excel Worksheet Functions 2 March 18th 05 02:11 AM


All times are GMT +1. The time now is 07:49 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"