Okay so my problem is that I don't realy know how to use the VBScript
engine in my project. So far I this is what I have done.
I don't understand how the .AddObject() works. I wrote a script and added it to
my scripts folder. When the application starts it reads all files with a .T5S
extention and adds it to the CompiledScript string. Once all the scripts are
loaded it adds the CompiledScript to the ScriptEngine and the state is set to
connected.
This is the code I have in my script.
However when I run the application the script above does not work. Any ideas
of what I am doing wrong.
engine in my project. So far I this is what I have done.
Imports System.IO
Imports MSScriptControl
Public Class Form1
Dim ScriptEngine As New ScriptControl
Dim CompiledScript As String
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ScriptEngine
.Language = "VBScript"
.AllowUI = True
End With
For Each Item In Directory.GetFiles(My.Computer.FileSystem.CurrentDirectory & "/Scripts".ToLower, "*.T5S")
Dim FileReader = My.Computer.FileSystem.ReadAllText(Item)
CompiledScript += FileReader & vbCr
Next
ScriptEngine.AddObject("PlayButton", Button1)
ScriptEngine.AddCode(CompiledScript)
ScriptEngine.State = ScriptControlStates.Connected
End Sub
End Class
I don't understand how the .AddObject() works. I wrote a script and added it to
my scripts folder. When the application starts it reads all files with a .T5S
extention and adds it to the CompiledScript string. Once all the scripts are
loaded it adds the CompiledScript to the ScriptEngine and the state is set to
connected.
This is the code I have in my script.
Sub PlayButton_Click
PlayButton.Backcolor = color.black
End Sub
Sub PlayButton_Enter
PlayButton.Backcolor = color.blue
End Sub
Sub PlayButton_Leave
PlayButton.Backcolor = color.red
End Sub
However when I run the application the script above does not work. Any ideas
of what I am doing wrong.