jeudi 24 mars 2016

Reference Variable names as strings

I am trying to reference the name of a variable as a string. I have a list of global variables

Public gvHeight As String = Blank
Public gvWeight As String = Blank
Public gvAge As String = Blank

I need to reference the name of the variables for an external API call. I am trying to avoid specific code per variable, instead allow me to add a new variable and everything reference correctly. I already have the rest of the code to deal with the name as a string.

example:

public Height as string
public weight as string
public age as string

[elsewhere in code]
for each var as string in {public variables}
   CallToAPI(var.name) 'needs to send "height" "weight" or "age" but there are a lot so hardcoding is not a good solution

edited for example





Aucun commentaire:

Enregistrer un commentaire