VBScript - Create a dynamic variable name based on another variable's value -


i have stored 'servicename' values in excel file parametrization (code - line 4).

format in excel:      servicename     (header)     eisordamd     entcanamd 

i want use dynamic variable names 3rd argument in 'fnexcquery' function based on parameters passed (line 5), i.e., 1st loop variable name should 'strquery_eisordamd' , 2nd loop should 'strquery_entcanamd'

1.  ststrquery_eisordamd = "select * eisordamd" 2.  strquery_entcanamd = "select * entcanamd" 3.  while (not objrecordset_testdata.eof) 4.      strservicename = trim(objrecordset_testdata.fields("servicename")) 5.      blnresponse_request = fnexcquery(struser, strpwd, strquery_<strservicename>)                     '1st loop: strquery_eisordamd ; 2nd loop: strquery_entcanamd  6.      objrecordset_testdata.movenext 7.  loop 

how create dynamic variable name 3rd argument. couldn't able find solution using vbscript, please help.

like eval() in other languages, need careful when executing dynamic code in fashion. having said that, can use execute() function execute string if vbscript statement. in case, you'd need use statement:

execute "blnresponse_request = fnexcquery(struser, strpwd, strquery_" & strservicename & ")"       

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -