Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Declaring a dynamic variable in a Vbscript

Posted on 2002-04-12
3
Medium Priority
?
454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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