Connecting Tech Pros Worldwide Help | Site Map

Convert String Value into a Variable name?

Newbie
 
Join Date: Dec 2006
Posts: 27
#1: Jul 22 '09
The title says it all, I need to converta string into a varialbe so that I can gain another value. here is the code so far:

Expand|Select|Wrap|Line Numbers
  1. sub ValidateValues()
  2.  
  3.     DFData = "DatadField1,DatadField2,DatadField3,DatadField4,DatadField5"
  4.     DFDataArry = split(DFData,",")
  5.  
  6.     DFTitle = "DF1Title,DF2Title,DF3Title,DF4Title,DF5Title"
  7.     DFTitleArray = split(DFTitle,",")
  8.  
  9.     dim DFF, DatadField, DF, Title
  10.  
  11.     for DfLoop = 0 to DfLoopCount
  12.  
  13.     DFF = DfLoop + 1
  14.  
  15.     if GetValue(DFDataArry(DfLoop)) = "" then
  16.         AddErrorMess("Value for" & GetValue(DFTitleArray(DfLoop)) & "has not been entered.")
  17.     end if
  18.  
  19.     response.Write( DFDataArry(DfLoop) )
  20.  
  21.     next
  22.  
  23.     if errormess <> "" Then
  24.  
  25.     response.Write("<p class=""red"">" & errormess & "</p>")
  26.  
  27.     end if
  28.  
  29. end sub
  30.  
  31. function AddErrorMess(errmess)
  32.  
  33.     if errormess = "" then
  34.         errormess = errormess & errmess
  35.     else
  36.         errormess = errormess & "<br>" & errmess
  37.     end if
  38.  
  39. end function
  40.  
  41. Function GetValue(sItem)  
  42.  
  43. GetValue = sItem.Value  
  44.  
  45. End Function 
As you can see I have a lop that goes through the 5 different variables.

Any Ideas?

Cheers
Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,081
#2: Jul 23 '09

re: Convert String Value into a Variable name?


Even after looking through your code I don't understand what you are trying to accomplish.

It is always a good idea to specify the Type expected for a variable...it's also a good idea to use better variable names than something like "DFF".

Anyways, I think you're interested in checking out Reflection. I'm not sure though because I don't have a clear understanding of what you're trying to do or Why.

-Frinny
Reply

Tags
convert, string, variables, vbscript