Visual Basic Script (VBScript)
Frequently Asked Questions (exontrol)
VBS.0:
In VBScript 32-bit you can use any of the following versions:
  • /COM indicates the 32-bit edition of the ActiveX version

The application built using /COM version runs on any Windows 32 or 64-bit machine.

In VBScript 64-bit you can use any of the following versions:

  • /COM/64 indicates the 64-bit edition of the ActiveX version

The application built using /COM/64 version runs on Windows 64-bit machine only. The application built using /COM/64 version cannot run on Windows 32-bit machine.

If you want to use your application on 32 and 64-bit machines, you can go for:

  • /COM/ANY indicates the 32 and 64-bit editions of the ActiveX versions

Should I use a 32-bit or 64-bit version of the control?

VBS.1:
The syntax for adding a component to a web page is:
<OBJECT classid="clsid:CLASSIDENTIFIER" id="IDENTIFIER">
</OBJECT>

where 

  • the IDENTIFIER is the ID of the object being added. The ID attribute can be used by a VB Script (via the HTML DOM) or by CSS to make changes or style the element with the specified id. The id attribute specifies a unique id for an HTML element
  • the CLASSIDENTIFIER is the object's class identifier as CD481F4D-2D25-4759-803F-752C568F53B7

The CLASSIDENTIFIER is unique for each /COM object, and can be found on control's documentation on the main object page, where something like follows is displaying, or explained here;

Tip The /COM object can be placed on a HTML page (with usage of the HTML object tag:  <object classid="clsid:...">)  using the class identifier: {CD481F4D-2D25-4759-803F-752C568F53B7}. The object's program identifier is: "Exontrol.G2antt". The /COM object module is: "ExG2antt.dll"

The following sample adds the eXG2antt component to a web page:

<OBJECT classid="clsid:CD481F4D-2D25-4759-803F-752C568F53B7" id="G2antt1">
</OBJECT>
VBS.2:
A) You can call the Init method during load event of the Body HTM element, like in the following sample:
<BODY onload='Init()'>
<OBJECT classid="clsid:CD481F4D-2D25-4759-803F-752C568F53B7" id="G2antt1" width="192" height="192">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With G2antt1
		.Columns.Add "Task"
		.Chart.FirstVisibleDate = #1/1/2001#
		With .Items
			.AddBar .AddItem("Task 1"),"Task",#1/2/2001#,#1/4/2001#
		End With
	End With
End Function
</SCRIPT>
</BODY>

B) You can add a SCRIPT right after the </OBJECT> so the code is executed once the object is created as in the following sample:

<OBJECT classid="clsid:CD481F4D-2D25-4759-803F-752C568F53B7" id="G2antt1">
</OBJECT>

<SCRIPT LANGUAGE="VBScript">
	With G2antt1
		.Columns.Add "Task"
		.Chart.FirstVisibleDate = #1/1/2001#
		With .Items
			.AddBar .AddItem("Task 1"),"Task",#1/2/2001#,#1/4/2001#
		End With
	End With
</SCRIPT>
VBS.3:
The syntax for handling the events with parameters is:
<SCRIPT LANGUAGE="VBScript">
Function IDENTIFER_EVENT(PARAMETERS)
	
End Function
</SCRIPT>

where the IDENTIFIER is the ID of the object being handled, and the EVENT is the name of the event being handled. The PARAMETERS gets the list of parameters that the event carries.

The following VBScript example displays a message box when the user clicks an anchor element in the gantt control:

<SCRIPT LANGUAGE="VBScript">
Function G2antt1_AnchorClick(AnchorID,Options)
	alert(AnchorID)
End Function
</SCRIPT>
The sample handles the AnchorClick event of the eXG2antt component.
VBS.4:
Initializes the control using the option A), as described on: Where I should initialize my control? ( using the load event of the BODY element ).
VBS.5:
Some of the events pass the parameters by reference. Such of event could be the KeyDown event, where the KeyCode parameter is passed by reference, so user can change it runtime. 

For instance, the following VBScript sample changes the TAB behavior, so if user presses the TAB, the control sends instead the RIGHT key, so it advance to the next editable field:

<SCRIPT LANGUAGE="VBScript">
Function G2antt1_KeyDown(KeyCode,Shift)
	if ( KeyCode = 9 ) then
		KeyCode = 39
	end if
End Function
</SCRIPT>

In this code, the KeyCode = 39, won't have any effect so instead you have to use the EventParam property like shown in the following sample:

<SCRIPT LANGUAGE="VBScript">
Function G2antt1_KeyDown(KeyCode,Shift)
	if ( KeyCode = 9 ) then
		G2antt1.EventParam(0) = 39
	end if
End Function
</SCRIPT>

or an equivalent sample:

<SCRIPT LANGUAGE="VBScript">
Function G2antt1_KeyDown(KeyCode,Shift)
	if ( KeyCode = 9 ) then
		G2antt1.Template = "EventParam(0) = 39"
	end if
End Function
</SCRIPT>
The EventParam property is available for almost all of our components. The Template property specifies the x-script code to be executed at runtime.
VBS.6:
The class identifier can be found on the control's documentation. 

You can follow the steps to find the classid ( for instance, we are trying to get the classid for the exg2antt control ): 

  • go to the control's main web page - exg2antt.jsp
  • click help under the control name - rhelp.jsp?product=exg2antt
  • locate and click the bold identifier (main object) in the control's objects list ( G2antt )

Under the object's help you will find:

Tip The /COM object can be placed on a HTML page (with usage of the HTML object tag:  <object classid="clsid:...">)  using the class identifier: {CD481F4D-2D25-4759-803F-752C568F53B7}. The object's program identifier is: "Exontrol.G2antt". The /COM object module is: "ExG2antt.dll"

VBS.7:
The ItemFromPoint(X as Long, Y as Long, ByRef ColIndex as Long, ByRef HitTestInfo as HitTestInfoEnum) method requires four parameters. Because, any variable on VBScript is of Variant type, the ColIndex and HitTestInfo can not be passed the right way. In order to get the result of the ItemFromPoint you need to use the ExecuteTemplate method like in the following sample:
<SCRIPT LANGUAGE="VBScript">
Function Grid1_MouseMove(Button,Shift,X,Y)
	With Grid1
		h = .ExecuteTemplate("Dim c, hit;ItemFromPoint(-1,-1,c,hit)")
		alert( h )
	End With
End Function
</SCRIPT>

instead of:

<SCRIPT LANGUAGE="VBScript">
Function Grid1_MouseMove(Button,Shift,X,Y)
	With Grid1
		Dim c, hit
		h = .ItemFromPoint(-1,-1,c,hit)	' Generates the Type mismatch: 'ItemFromPoint'
		alert( h )
	End With
End Function
</SCRIPT>

In the same way, if you require to access the c or hit variables you should use a code like:

<SCRIPT LANGUAGE="VBScript">
Function Grid1_MouseMove(Button,Shift,X,Y)
	With Grid1
		h = .ExecuteTemplate("Dim c, hit;ItemFromPoint(-1,-1,c,hit);c=c")
		alert( h )
	End With
End Function
</SCRIPT>