Creating a variable based on the value of another?

Okay, so I need a way to set a variable without directly having the name of it there, and instead get the name from another variable.

(Example of what I mean):

//setting variable name we’ll use.
Dim variablename as String = “carrots”

//creating a variable with the name we set before
Dim (variablename) as Integer = 10

MsgBox "You have: " + carrots + “Carrots.”
//Outputs: You have: 10 Carrots.

So how could I go about doing something like this? It’s pretty important for a program I’m working on, and this seems like a commonly available feature of most languages.

Do it as you wrote it in the code editor ?

Why do you want to use the same name ?

That said, create the first in a Module, set it protected (to call it as ModuleName.VariableName) and declare the second normally where you need it.
That said it looks strange to me.

I need to make the variables on the fly, some of them might have totally random names every time, it’s all based on the user’s end, so I can’t really use premade lists of variable names.

Is there any kind of function to create a variable where it gets the name from a string?

Check Dictionary in case if fit your needs.

http://documentation.xojo.com/api/language/dictionary.html

or Pair
Var p As New Pair(“Carrots”, 10)
if you have more than one use a array or dictionary,own class or struct.

No, but a Dictionary would fit the bill.

I’d create a class