Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Executing a String from an Array

Posted on 1998-08-18
5
Medium Priority
?
143 Views
Last Modified: 2010-05-18
I have a series of strings in an array.  These strings are actually VB commands that I want to execute.  How can I tell VB to execute a certain index from an array?
0
Comment
Question by:IsleOfView
[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
5 Comments
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1429611
It depends on what you want to do.  Give a specific example of what you want to do.  


Specialist

0
 

Author Comment

by:IsleOfView
ID: 1429612
Well, let's go from just the simplest example.
let's say that:

Array(0) = MsgBox "Hello World!"
Array(1) = MsgBox "Hello Again!"

Whatever--I would like to have these strings act as if they were a part of the module I am working in.  They should be able to call functions from other modules as well.

TIA
0
 
LVL 3

Expert Comment

by:Foyal
ID: 1429613
Sub AMessage(Index as Integer)
    Msgbox Array(Index)
End Sub
0
 

Author Comment

by:IsleOfView
ID: 1429614
Perhaps I'm not being clear--I don't know for sure that the array is going to contain, say, a msgbox command.  It might be something changing a property...The idea is to use the string contained in the array as a VB statement.
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 200 total points
ID: 1429615
Umm, this idea can't work. VB is *COMPILED*, there is no way to dynamically interprit code at runtime. Your only option would be a *HUGE* task to write a VB emulator. There is just no concept of interpritted code in a compiled program.
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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 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