Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute the contents held within a variable

Status
Not open for further replies.

ds2728

Programmer
Jul 18, 2001
50
US
Hello,

I would like to execute the contents of a variable within my code. simple example is:

counter= 10
newvar = "counter + 5"

how do I get newvar to equal 15.

thanks,
dave

 
Lose the quotes...

Sub test()
Dim counter as Long
Dim lngNewVar as Long

lngCounter = 10
lngNewVar = lngCounter + 5

MsgBox lngNewVar
'Returns 15

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top