Solved

UDT and VBScript /Jscript

Posted on 1998-10-13
7
539 Views
Last Modified: 2012-06-22
I've written an ActiveX DLL with methods which use user defined types.

Is it possible to invoke these methods from VBscript or Jscript embedded in an HTML page?

Thanks
0
Comment
Question by:gdg60
7 Comments
 
LVL 2

Expert Comment

by:mitchell042997
Comment Utility
I don't know if you can do it using an ActiveX DLL, but you can using an ActiveX control.  For the DLL, I would recommend using Active Server Pages script.  

You can find more information on my site, at:

   http://www.4guysfromrolla.com/webtech/091698-1.shtml

To do the ActiveX control, use the OBJECT tag in your HTML.  For example, say you created a DLL which had some structure as a private data member, and some method like, PrintStructure().  You could, in your HTML, do:

<OBJECT NAME="MyActiveXDLL" CLASSID="CLSID:........">
</OBJECT>

<SCRIPT LANGUAGE="JScript">
  document.MyActiveXDLL.PrintStructure();
</SCRIPT>

This is explained in more detail detail on my website.  (http://www.4GuysFromRolla.com).  Happy Programming!
0
 

Author Comment

by:gdg60
Comment Utility
Probably I've not been very clear.

The problem is not how to call an object from an html page or an asp page, but if I can use, from VBscript or Jscript, a method that accepts a user defined type as parameter.

Example
myObject.MyMethod(par)
where par is a user defined type
Thanks .
0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
So what is a user defined type in this case?

Michel
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:gdg60
Comment Utility
Dear Michel

with VB6 you can write a demo class (clsDemo) like this.
-------
Public Type TestStru ' Create user-defined type.
   FieldA As Integer  
   FieldB As String
End Type


Public Sub PrintStructure(Struct As TestStru)
  MsgBox Struct.FieldA & " " & Struct.FieldB  
End Sub
--------
and then compile it to create an ActiveX DLL.

You can easily use this DLL from a VB or VC main.

...
...
dim str as TestStru
Dim b as clsDemo

..
str.fieldA = 1
str.fieldB = "Mickey Mouse"
..
b.PrintStructure str
..

and see the message box showing "1  Mickey Mouse"

My question is. Is it possible use the PrintStructure method from a VBScript or Jscript procedure ?

Thanks and Ciao from Italy

PS: Sorry for my english.. it's the best I can do


0
 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Sorry I have never seen it done.

if document.myActiveX.PrintStructure(2,'hello there'); does not work, I do not have any idea...
Cant you have
document.myActiveX.SetFieldA(2);
document.myActiveX.SetFieldB('Hello there');
document.myActiveX.CreateUDT('FieldA','FieldB');
document.myActiveX.PrintStructure();

Michel
0
 
LVL 10

Expert Comment

by:kollegov
Comment Utility
I'm not sure for ActiveX, but I have some experience with Java applets methods envoking..
The problem is that JavaScript can pass set of simple parameters only,
allowed types are String, int and Float.
So you just can make wrappers for your methods which
create structure from a set of single parameters and pass it to your method.
I'm pretty sure this is the only way :(
0
 

Accepted Solution

by:
dtseng earned 20 total points
Comment Utility
I think the quick answer is No.  What you may try doing is (edited text in CAPS):

      Public Type TestStru ' Create user-defined type.
         FieldA As Integer  
         FieldB As String
      End Type

      Public FUNCTION PrintStructure(Struct As TestStru) as String
        RETURN Struct.FieldA & " " & Struct.FieldB  
      End Sub
      --------
      and then compile it to create an ActiveX DLL.

      You can easily use this DLL from a VB or VC main.

      ...
      ...
      dim str as TestStru
      Dim b as clsDemo

      ..
      str.fieldA = 1
      str.fieldB = "Mickey Mouse"
      ..
      MSGBOX b.PrintStructure str
      ..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now