Connecting Tech Pros Worldwide Forums | Help | Site Map

Execute VB code from a string

Moderator
 
Join Date: Oct 2006
Location: Australia
Posts: 7,748
#1   Mar 26 '07
In VB5 or VB6, to execute VB code from a string (for example, a textbox) add the Microsoft Script Control under Project | Components.

Here is some sample code which shows one way to make use of it...
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   Text1.Text = "cmdText1.Visible = False"
  3.   Call ScriptControl1.AddObject(cmdText1.Name, cmdText1)
  4. End Sub
  5.  
  6. Private Sub Command1_Click()
  7.   Call ScriptControl1.ExecuteStatement(Text1.Text)
  8. End Sub
Further information is available by searching TheScripts or the entire web for “microsoft script control”.

By Steve Gerrard (guest) in Community > Newsgroup Archive > comp.lang.* > Visual Basic > How do I Execute the content of a textbox

Brought to the group’s attention by Phaneendra Varma

Last edited by RedSon; Nov 21 '07 at 09:49 PM.



Reply