Convert String Value into a Variable name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • adz1809
    New Member
    • Dec 2006
    • 27

    Convert String Value into a Variable name?

    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:

    Code:
    sub ValidateValues()
    
    	DFData = "DatadField1,DatadField2,DatadField3,DatadField4,DatadField5"
    	DFDataArry = split(DFData,",")
    
    	DFTitle = "DF1Title,DF2Title,DF3Title,DF4Title,DF5Title"
    	DFTitleArray = split(DFTitle,",")
    	
    	dim DFF, DatadField, DF, Title
    
    	for DfLoop = 0 to DfLoopCount
    	
    	DFF = DfLoop + 1
    	
    	if GetValue(DFDataArry(DfLoop)) = "" then
    		AddErrorMess("Value for" & GetValue(DFTitleArray(DfLoop)) & "has not been entered.")
    	end if
    	
    	response.Write( DFDataArry(DfLoop) )
    	
    	next
    	
    	if errormess <> "" Then
    	
    	response.Write("<p class=""red"">" & errormess & "</p>")
    
    	end if
    
    end sub
    
    function AddErrorMess(errmess)
    
    	if errormess = "" then
    		errormess = errormess & errmess
    	else
    		errormess = errormess & "<br>" & errmess
    	end if
    
    end function
    
    Function GetValue(sItem)  
       
    GetValue = sItem.Value  
      
    End Function
    As you can see I have a lop that goes through the 5 different variables.

    Any Ideas?

    Cheers
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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

    Comment

    Working...