?
Solved

Declaring a dynamic variable in a Vbscript

Posted on 2002-04-12
3
Medium Priority
?
443 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

Independent Software Vendors: 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 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…
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/…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

770 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