|
-
January 10th, 2010, 12:20 PM
#17
Re: passing variable name rather than the variable
Yes, as I said, you have to know what you are doing with CopyMem.
Well, come to think of it, there is another neat solution which simply uses a good old well known VB object, without a new class or fancy tricks. Look at this:
Code:
Private Fruit As New Collection
Private LastFruit As String
Private Sub Form_Load()
Fruit.Add 10, "apple"
Fruit.Add 10, "banana"
Fruit.Add 10, "orange"
End Sub
Private Sub ChangeFruit(FruitName, Increment)
Fruit(FruitName) = Fruit(FruitName) + Increment
End Sub
'and you can do
LastFruit = "apple"
ChangeFruit LastFruit, 10
Items in a collection act exactly like named variable, if you use the key as an index to retrieve the value, the key being a name which is nothing more than a string.
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
|