Hi Jim
Thanks for your reply but still having difficulties in getting it to work..
I have included a little test form and the code i getting the problem with
....
maybe you could shed some light
you can download the code in frm and frx and also a workbook from
http://homepage.ntlworld.com/nick.ca...xcel/array.zip
Option Explicit
Dim WidthArray(), DropArray() As Variant
Dim arrayname, arraysize As Variant
Dim arraydata As String
Sub UserForm_Initialize()
opt_Width.value = True
End Sub
Private Sub butAdd_Click()
arraydata = txtInputValue.value
Call AddToArray(arrayname, arraydata)
End Sub
Private Sub opt_Drop_Click()
arrayname = "DropArray()"
End Sub
Private Sub opt_Width_Click()
arrayname = "WidthArray()"
End Sub
Private Function AddToArray(ByRef arrayname As Variant, arraydata) As
Variant
'get the current size of the array + 1
arraysize = UBound(arrayname) - LBound(arrayname) + 1
're dim the array to preserve the data and increase the storage
ReDim Preserve arrayname(arraysize, 2)
arrayname(arraysize, 0) = arraysize
arrayname(arraysize, 1) = arraydata
End Function
See if you can see what i am doing wrong.... !!!
Thanks
"Jim Thomlinson" wrote in message
...
An array is a variable not an object so it sould be passed more like
this...
I assume you know what type of varaibles the array holds. If not then
specify
variant
public function dosomethingwitharray (arrayname() as string) as variant
test1 = ubound(arrayname)
test2 = lbound(arrayname)
' do something with array
End function
--
HTH...
Jim Thomlinson
"devo" wrote:
Hi
Could someone please explain how to do the following
I wish to have a function which i can pass a string which is an array
name
and then be allowed to manipulate the array
ie
array_width or array_drop
function dosomethingwitharray (arrayname as object)
test1 = arrayname.ubound
test2 = arrayname.lbound
' do something with array
End function
but i seem to be getting erros with setting and passing the arrayname