Link to home
Start Free TrialLog in
Avatar of LuckyLucks
LuckyLucks

asked on

trying to retreive value of a variable after contructing it as a string

 Dim FullName As String
  FirstInitialLetter = Mid(LTrim(RTrim(FullName)), 1, 1) & "_" & "score"
 
  Dim score As Double = FirstInitialLetter

   My program has a set of double variables A_score, B_Score,...,Z_score and I am trying to fetch the correct
   variable based on the first letter of the fullname,i.e, if FullName='Robert Dunn' then the FirtInitialLetter    reduces to R_score as a string and I was hoping to be able to extract the corresponding double variable called    R_score's value into score. But I get the error: Cant cast a string as a double in line 3. It is misinterpreting the FirstinitialLetter as a string and I want it to read it as a variable name. Please help!!

Thnaks
Avatar of YZlat
YZlat
Flag of United States of America image

data type Double is a number and you are trying to assign a string to it
For example FirstInitialLetter will contain a value "R_score". What value do you expect to get in a variable "score"?
Hi LuckyLucks,

if you have your scores in a array with the string R_Score as the identifier in column 1 and a second column for the value as double you can look up those values and assign them to score

hope this helps a bit
bruintje
Avatar of LuckyLucks
LuckyLucks

ASKER

I am looking to stuff into score the double value contained in the variable R_score. So far I have only been able to get a string called R_score. How can I now get its value?

Thanks
do not think you can do this 'directly' without using something like an array

in this case you have a variable name string and a variable double those are 2 different things but i could be wrong
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ah, that should be it :)
Thanks to everyone for contributing