I have a list of field names and constants for the corresponding field length that I would like to dynamically set the name for.
for example
i have const kCitylen =31
I can use select case if need be but was hoping not to have to add 20 or so cases
The idea is to display an edit box to allow interactive truncation
The problem portion is shown below
dim field_name as string = "City"
dim field_val as string = "Any City 1234567890123456789123456789"
dim const_name as string
const_name= "k" + field_name + "len"
left(field_val,const_name)
create a dictionary instead. the names of constants , variables etc cannot be changed at runtime… that is a feature usually only found in an interpeted language.
Those two are mutually exclusive. By definition a constant is, well, constant. When you need a dynamically set value, use something other than a constant. Such as the dictionary mentioned by Dave.