Jump to content

ScriptControl Add object with .AddCode


Recommended Posts

Hello :)

I'm not so familiar with the scriptcontrol, can you help me with this little problem?

Why is this script not working correctly?

Global $oVbs = ObjCreate('MSScriptControl.ScriptControl')
With $ovbs
    .Language = "VBScript"
    .AllowUI = True
    .AddCode('Class Test:Public Function X:X = 123:End Function:Set C = New Test')
    .AddCode('MsgBox IsObject(C)'); should be true, no?
EndWith

MsgBox(0,'',$oVbs.Eval('C').X)

Also: how do I add code to the global module?

Thanks,

TheAutomator

Edited by TheAutomator
Link to comment
Share on other sites

You're not Closing your Class 

 

Global $oVbs = ObjCreate('MSScriptControl.ScriptControl')
With $ovbs
    .Language = "VBScript"
    .AllowUI = True
    .AddCode('Class Test:Public Function X:X = 123:End Function:End Class:Set C = New Test')
    .AddCode('MsgBox IsObject(C)'); should be true, no?
EndWith

MsgBox(0,'',$oVbs.Eval('C').X)

 

Saludos

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...