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

x
?
Solved

Writing code at runtime

Posted on 2001-06-07
5
Medium Priority
?
160 Views
Last Modified: 2010-05-02
This is in the Access section but is appropriate for this area as well.

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=msaccess&qid=20131698
0
Comment
Question by:xSinbad
[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
  • 2
5 Comments
 
LVL 3

Expert Comment

by:wpsjr1
ID: 6166237
Use the MS Scripting Control, its accessable in VB at least.  You would add code using visual basic script.
0
 
LVL 5

Expert Comment

by:aminerd
ID: 6166377
xSinbad,

Check out the Microsoft Scripting Control. With it you can execute code at runtime. For instance (in VB):

Sub RunCode()
 
  Dim strCode As String
  strCode = "Call MsgBox(""Hello!"")"
 
  Dim objScript As ScriptControl
  Set objScript = New ScriptControl
 
  'A message box will pop up
  Call objScript.Execute(strCode)
 
  Set objScript = Nothing
 
End Sub
0
 
LVL 5

Accepted Solution

by:
aminerd earned 40 total points
ID: 6166380
You can also allow the code to access objects in your program by using the AddObject method...

Sub RunCode()
 
  Dim strCode As String
  strCode = "frmMain.lblHi.Caption=""Hello!"""
 
  Dim objScript As ScriptControl
  Set objScript = New ScriptControl
 
  'Assuming this sub is in a form with a label called lblHi
  Call objScript.AddObject("frmMain", Me, True)
  Call objScript.Execute(strCode)
 
  Set objScript = Nothing
 
End Sub
0
 
LVL 6

Author Comment

by:xSinbad
ID: 6166392
Thanks wpsjr1 and aminerd I will check that out tonight.

Cheers
Marcus
0
 
LVL 6

Author Comment

by:xSinbad
ID: 6179351
Thanks for the extra info aminerd.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

705 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