Posted: Mon May 18, 2009 10:54 pm Post subject: simple array question
I apologize for posting this. I know I should have found it in some archive somewhere, but I think my ignorance is preventing me from even making the correct query.
I am relatively new to VBA, but I know several other languages. I am trying to figure out how VBA deals with arrays. I made a test program that does not work:
[code]
Public Function tempo(list)
list(1) = 2
tempo = list(1)
End Function
[/code]
If I comment out the first line, I get as output whatever the first element is in my input range in Excel. If I uncomment the first line, I get the #VALUE! error, instead of 2 as expected. This leads me to believe that what I am calling "list" is not understood as an array in VBA, but as some other data type. After a couple hours of playing, it seems that I can use arrays as I expect from other programming languages as long as I don't try to assign a value to an element of it. As soon as I do I get an error.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum