Anthony's VBA Forum Index Anthony's VBA Forum
Where the knowledge is shared
Menu
 Anthony's VBA Forum IndexHome Page
 Anthony's VBA Forum IndexForum Index
FAQFAQ
MemberlistMemberlist
UsergroupsUsergroups
RegisterRegister
ProfileProfile
Log in to check your private messagesMessages
Log inLogin/Out

Quick Search

Advanced Search

Links
Consulting
Products

Who's Online
[ Administrator ]
[ Moderator ]


simple array question

 
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA
View previous topic :: View next topic  
Author Message
trn



Joined: 18 May 2009
Posts: 1

PostPosted: Mon May 18, 2009 10:54 pm    Post subject: simple array question Reply with quote

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.

What gives?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Anthony's VBA Forum Index -> General Excel VBA All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2002 phpBB Group