VbScript and Events
Posted: Tue Feb 01, 2005 7:39 pm
Hi,
I'm working whit the TChart and VbScript, but I have a problem with the
TChart's events.
When I attach the TChart control to the Scrip Object the properties work
correctly, but the events don't trigger in the Script
This is a example
In a VbProjects add a TChart, RichTextBox, TextBox and a CommandButton objects, and add reference to msscript.ocx
Add the next source in a form
Private WithEvents m_scriptEngine As MSScriptControl.ScriptControl
Private Sub Command1_Click()
m_scriptEngine.AddCode Text1
m_scriptEngine.Run "Activate"
m_scriptEngine.State = Connected
End Sub
Private Sub Form_Initialize()
Set m_scriptEngine = New MSScriptControl.ScriptControl
m_scriptEngine.Language = "VBScript"
m_scriptEngine.AllowUI = True
m_scriptEngine.UseSafeSubset = False
m_scriptEngine.SitehWnd = Me.hWnd
End Sub
Private Sub Form_Load()
m_scriptEngine.AddObject "TChart1", TChart1.Object
m_scriptEngine.AddObject "TChart", TChart1
m_scriptEngine.AddObject "RichTextBox1", RichTextBox1.Object
m_scriptEngine.AddObject "RichTextBox", RichTextBox1
Text1 = "Sub Activate" & vbCrLf & _
" msgbox " & """" & "Activate" & """" & vbCrLf & _
" RichTextBox.Text = " & """" & "VbScript Test" & """" & vbCrLf & _
" TChart.Aspect.View3d = False " & vbCrLf & _
"End Sub" & vbCrLf & vbCrLf & _
"Sub TChart1_OnClick()" & vbCrLf & _
" msgbox " & """" & "OnClick" & """" & vbCrLf & _
"End Sub" & vbCrLf & vbCrLf & _
"Private Sub RichTextBox1_Change()" & vbCrLf & _
" msgbox " & """" & "Change" & """" & vbCrLf & _
"End Sub"
End Sub
Regards
Gustavo.
I'm working whit the TChart and VbScript, but I have a problem with the
TChart's events.
When I attach the TChart control to the Scrip Object the properties work
correctly, but the events don't trigger in the Script
This is a example
In a VbProjects add a TChart, RichTextBox, TextBox and a CommandButton objects, and add reference to msscript.ocx
Add the next source in a form
Private WithEvents m_scriptEngine As MSScriptControl.ScriptControl
Private Sub Command1_Click()
m_scriptEngine.AddCode Text1
m_scriptEngine.Run "Activate"
m_scriptEngine.State = Connected
End Sub
Private Sub Form_Initialize()
Set m_scriptEngine = New MSScriptControl.ScriptControl
m_scriptEngine.Language = "VBScript"
m_scriptEngine.AllowUI = True
m_scriptEngine.UseSafeSubset = False
m_scriptEngine.SitehWnd = Me.hWnd
End Sub
Private Sub Form_Load()
m_scriptEngine.AddObject "TChart1", TChart1.Object
m_scriptEngine.AddObject "TChart", TChart1
m_scriptEngine.AddObject "RichTextBox1", RichTextBox1.Object
m_scriptEngine.AddObject "RichTextBox", RichTextBox1
Text1 = "Sub Activate" & vbCrLf & _
" msgbox " & """" & "Activate" & """" & vbCrLf & _
" RichTextBox.Text = " & """" & "VbScript Test" & """" & vbCrLf & _
" TChart.Aspect.View3d = False " & vbCrLf & _
"End Sub" & vbCrLf & vbCrLf & _
"Sub TChart1_OnClick()" & vbCrLf & _
" msgbox " & """" & "OnClick" & """" & vbCrLf & _
"End Sub" & vbCrLf & vbCrLf & _
"Private Sub RichTextBox1_Change()" & vbCrLf & _
" msgbox " & """" & "Change" & """" & vbCrLf & _
"End Sub"
End Sub
Regards
Gustavo.