Dynamic Objects in VBS 
Author Message
 Dynamic Objects in VBS

Hi

Does anyone know how to create dynamic Objects in VBS and have Methods Named
dynamically. I know that objects and Methods can be created dynamically with
JScript.

JScript Sample:
------------
function myClass() {
 this.myFunction = _myFunction;

Quote:
}

function _myFunction(Parameter) {
    alert(Parameter);
Quote:
}

var obj = new myClass();
obj.myFunction('Test');

VBS Ssample:
-------------
Class MyClass
 Function MyFunction(Parameter)
  MsgBox Parameter
 End Function
End Class

Dim obj
obj = new MyClass
obj.MyFunction("Test")

Conrad



Mon, 09 Dec 2002 03:00:00 GMT  
 Dynamic Objects in VBS
Hi

Does anyone know how to create dynamic Objects in VBS and have Methods Named
dynamically. I know that objects and Methods can be created dynamically with
JScript.

JScript Sample:
------------
function myClass() {
 this.myFunction = _myFunction;

Quote:
}

function _myFunction(Parameter) {
    alert(Parameter);
Quote:
}

var obj = new myClass();
obj.myFunction('Test');

VBS Ssample:
-------------
Class MyClass
 Function MyFunction(Parameter)
  MsgBox Parameter
 End Function
End Class

Dim obj
obj = new MyClass
obj.MyFunction("Test")

Conrad



Mon, 09 Dec 2002 03:00:00 GMT  
 Dynamic Objects in VBS
Well sort of -- using ExecuteGlobal...

str = "Class MyClass" & vbcrlf
str = str & " Function MyFunction(Parameter)" & vbcrlf
str = str & "  MsgBox Parameter" & vbcrlf
str = str & " End Function" & vbcrlf
str = str & "End Class"

ExecuteGlobal str

Dim obj
set obj = new MyClass
obj.MyFunction("Test")

--
Michael Harris
MVP Scripting


Hi

Does anyone know how to create dynamic Objects in VBS and have Methods Named
dynamically. I know that objects and Methods can be created dynamically with
JScript.

JScript Sample:
------------
function myClass() {
 this.myFunction = _myFunction;

Quote:
}

function _myFunction(Parameter) {
    alert(Parameter);
Quote:
}

var obj = new myClass();
obj.myFunction('Test');

VBS Ssample:
-------------
Class MyClass
 Function MyFunction(Parameter)
  MsgBox Parameter
 End Function
End Class

Dim obj
obj = new MyClass
obj.MyFunction("Test")

Conrad



Mon, 09 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. vbs dynamic parameter

2. Passing VB OLE objects in the Application object (IIS3, VB5, ASP, VBS)

3. onclick event for dynamic TD object

4. Dynamic select objects

5. get dynamic properties of an object

6. Can you create an Object with Dynamic HTML

7. Can you create an Object with Dynamic HTML

8. Request Object and dynamic form item names

9. Dynamic Data Structures: Dynamic Arrays?

10. dynamic forms inside dynamic tables

11. Dynamic Object

12. Dynamic Objects with VB.net

 

 
Powered by phpBB® Forum Software