Solved

Declaring a dynamic variable in a Vbscript

Posted on 2002-04-12
3
429 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 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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