Solved

Declaring a dynamic variable in a Vbscript

Posted on 2002-04-12
3
416 Views
Last Modified: 2008-03-03
I there a way in vbscript to declare a dynamic variable?

For example:

 Myvariable & i= "Some Text"

 I know you can do it in JavaScript by using a
build in function called Eval,
Eval(Myvariable + i)= "Some Text";
0
Comment
Question by:7of9121098
  • 2
3 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 6937503
you can use javascript together with vbscript to do this:


<HTML>
<HEAD>

<SCRIPT language='javascript'>

 eval("var variable" + 1 + " = 'a'");
 eval("var variable" + 2 + " = 'b'");
 eval("var variable" + 3 + " = 'c'");

 alert(variable1);
 alert(variable2);
 alert(variable3);

 function jsEval(jscode)
 {
   return(eval(jscode));
 }

</script>

<SCRIPT language='vbscript'>

 msgbox(variable1)
 msgbox(variable2)
 msgbox(variable3)

 dim v4
 jsEval("v4 = 'd'")
 msgbox(v4)

</script>

</head>

<BODY>
</body>
</html>
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 50 total points
ID: 6937508
will also work with server-side code in ASP:


<SCRIPT language='javascript' runat='server'>
 function jsEval(jscode)
 {
   return(eval(jscode));
 }
</script>


<%
 dim v4
 jsEval("v4 = 'd'")
 response.write v4
%>
0
 

Author Comment

by:7of9121098
ID: 6937538
Excellent...
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question