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
Visual Basic.NET

Avatar of undefined
Last Comment
LuckyLucks
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
Avatar of YZlat
YZlat
Flag of United States of America image

For example FirstInitialLetter will contain a value "R_score". What value do you expect to get in a variable "score"?
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

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
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

ah, that should be it :)
Avatar of LuckyLucks
LuckyLucks

ASKER

Thanks to everyone for contributing
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo