Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic, Web
Expertise: Intermediate
Feb 4, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Retrieve a Functional Reference Using GetRef in VBScript

Browsers Targeted: Internet Explorer 4+

One of the capabilities that JavaScript has long had that VBScript hasn't supported is being able to associate an event handler with a specific function. For example, if you define an initialization routine that is fired when the document loads, attaching it to the window object involves simply passing the functional reference to that function:

<script language="JavaScript">
	function Initialize(){
		// Put some initialization code here
// Functional reference has no parentheses.

You simply couldn't do this in VBScript, which has limited its appeal considerably for client-side scripting. However, with Visual Basic 5 (released with later versions of Internet Explorer 4), you can use the GetRef() function to retrieve a functional reference to a given function. The previous JavaScript code would then look like this in VBScript:

<script language="VBScript">
	function Initialize()
		// Put some initialization code here
	end function

In this case, the functional reference is passed as a string containing the name of the function.

Kurt Cagle
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date