samedi 13 juin 2015

VB.NET - How to call a string with it's na

I have a program written in vb.net that contains a lot of variables very similar to each others. For example, one of them is

Public Shared iPhone4S_Firmware_8_0_Key = key

As you can see, my variables are composed by the model of the iPhone (iPhone 4S/5, etc.) and the firmware version (8.0/8.0.1, etc.) Now, when the user selects a combo of 'device' + 'firmware', my tool has to export the right variable (depending from the user's choice) in another string called 'active'.

I could do this manually with an if/then combination, but it would be a mess. So I'd like to proceed in this way:

Dim active as String = iPhoneModel + "_Firmware" + version + "_Key"

As you can guess, 'iPhoneModel' and 'version' are two other strings. So in this way I can always compose the right variable dynamically, but the problem is that if I write

Dim active as String = iPhoneModel + "_Firmware" + version + "_Key"

It thinks that 'iPhoneModel + "_Firmware" + version + "_Key"' is the content of the new variable.. So how can I say that the program has to take the content from the already existing variable with that name; and NOT to take that name as variable's content?




Aucun commentaire:

Enregistrer un commentaire