01-15-2019 08:58 PM
Is it possible to create a new Variable using a value from a Field?
For instance, if a Field value is "Address1" I like to create a new Variable called Address1
"Dim [Variable Name] as string = [Field value]"
In Visual FoxPro, I could use a macro expression to create a new variable:
"&[Variable Name] = [Field value]"
Does this work in vb.NET? If so, would you show a code snippet to do this?
Thursday - last edited Thursday
Being an old VFP guy myself I would love .NET to do some of the stuff we had years ago in Fox.
There are two ways I have found workarounds.
1) declare a dictionary of variable ( or a two dimensional array ) where you can store them.
Dim variables As New Dictionary(Of String, Integer)()
variables("MyDynamicVariable") = 10 ' Set the value of the "variable" Dim value As Integer = variables("MyDynamicVariable") ' Retrieve the value of the variable
2) The second is to dynamically compile on the fly.
There are many pros and cons to this methodology. I use it heavily for scripting in Impact Suite and took weeks to write.
There is too much code to show an example so here is a link to the MS topic.
Here's a good article by Rick Strahl, (he's an old VFP guy too)
Hope this helps
-- Jim Durkin