Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to call VBScript code into my VB Application

Status
Not open for further replies.

josan

Programmer
Mar 25, 2002
11
ES
Hello!

I am thinking to develope an application as follows:

The forms would be defined in some .xml files using this protocol:

<FORM Name = "MyForm">
<PROPERTY Name="Caption" Value="My application"/>
<PROPERTY Name="../>
...
<EVENT Name="Load">
MsgBox "Hello!"
</EVENT>
<CONTROL License="MSFlexGridLib.MSFlexGrid" ProgId = "MSFlexGridLib.MSFlexGrid" Name="grd1">
<PROPERTY Name="Cols" Value="3"/>
...
<EVENT Name="RowColChange">
...
</EVENT>
</CONTROL>
...
</FORM>

I have a component who reads the .xml file and builds the form using a Visual Basic form, changing the properties of the form using something like the "CallByName" function, and adding the controls defined in the .xml file, using the "Add" method. This component has a "CControl" class that use a VBControlExtender to contain each ActiveX controls of the form.

When an event is raised, the component "looks" if the control who raises the event has some "actions" to do. As you can see in the definition of the form, for each event of each "OBJECT", you can define "what to do" using VBScript code. But I have some questions about this design:

1) How can I parse this VBScript code? I think that it could be better if I write all the VBScript in an independent file, and all the services inside a class / some classes. So, how can I do it?

2) How can I catch the objects of my form from the VBScript code? For exemple, I would like to use the MSFlexGrid control to change then number of Rows when the "RowColChange" event is raised.

3) I make this desing because I want to automate the creation of the interface. My goal is not to compile any code when I change the interface. Does exist another better way to do it?

I hope somebody could help me. Thanks in advance!
 
It's me again,

I have seen that exists a component that allows you to execute scripts codes (VBScript or JavaScript). This component is the MSScriptControl.ScriptControl (References-> Microsoft Script Control 1.0)

This object has some methods like AddCode and AddObject that allows you to make VBScripts codes and use them for my applications. What is more, I can define some modules of my VBScript procedures and functions. With the AddObject method I am able to work with the "OBJECTS" (form and controls) of my VB forms.

Also I still have two questions:

1) I haven't seen how can use methods defined into a VBScript class using the MSScriptControl.ScriptControl object.

2) There is another better way to do what I want to do?

Thank you!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top