|
-
Mar 11th, 2002, 09:56 AM
#1
Thread Starter
Hyperactive Member
Multi-type parameters
VB Code:
Private Sub Form_Load()
Dim myArray() As Single
MsgBox getSize(myArray)
End Sub
Private Function getSize(inArray() As Variant) As Integer
On Error Resume Next
getSize = 0
getSize = UBound(inArray)
End Function
This won't work because the getSize function expects a Variant array.
Apart from a great long list of optional paramaters and loads of ElseIf statements is there any way to write a function that will accept any data type array? Any data type actually.
This really bugs me.
-
Mar 11th, 2002, 09:59 AM
#2
VB Code:
Private Function getSize(inArray() As ParamArray) As Integer
On Error Resume Next
getSize = 0
getSize = UBound(inArray)
End Function
-
Mar 11th, 2002, 10:03 AM
#3
This also worked for me (I guess for the same reasons)
VB Code:
Private Function getSize(inArray As Variant) As Integer
This world is not my home. I'm just passing through.
-
Mar 11th, 2002, 10:05 AM
#4
Thread Starter
Hyperactive Member
VB Code:
Private Function getsize(ParamArray inArray()) As Integer
On Error Resume Next
getsize = 0
getsize = UBound(inArray)
End Function
Thanks WALDO, I had to put ParamArray first to get it to work like above, don't know why.
I wish I'd asked before making loads of copies of functions for working with arrays.
-
Mar 11th, 2002, 10:11 AM
#5
Thread Starter
Hyperactive Member
Its not working
VB Code:
Option Explicit
Private Sub Form_Load()
Dim myArray() As Single
Dim i As Integer
i = 9
ReDim Preserve myArray(i)
MsgBox getSize(myArray)
End Sub
Private Function getSize(ParamArray inArray()) As Integer
On Error Resume Next
getSize = 0
getSize = UBound(inArray)
End Function
returns 0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|