Use variabel as reference

  • Thread starter Thread starter Andres Angel
  • Start date Start date
A

Andres Angel

Hi Everyone:
I need some help here.
The code below is just a sample of what I'm trying to do.

I need to use the value in a variable as the reference for
another variable.
In the code below I will create "xy2" in "zz" then
display "zz". If the code is correct it should
display "Congratultaions!!!" the value for "xy2".

How can I do that change in reference?

Sub xref()
xy2 = "Congratulations!!!"
yy = 2
zz = "xy" & yy
MsgBox zz
End Sub


Andres Angel
 
pass the variable to it

sub passme()
dim xy2 as string
xy2 = "Congratulations!!!"
ref xy2
end sub


Sub xref(var as string)
yy = 2
zz = var & yy
MsgBox zz
End Sub


Sub xref()
xy2 = "Congratulations!!!"
yy =Sub xref()
xy2 = "Congratulations!!!"
yy = 2
zz = "xy" & yy
MsgBox zz
End Sub
2
zz = "xy" & yy
MsgBox zz
End Sub
 
Sub xref()
Dim xy(1 To 10), yy, zz
xy(2) = "Congratulations!!!"
yy = 2
MsgBox xy(yy)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top