Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

UDT and VBScript /Jscript

Posted on 1998-10-13
7
Medium Priority
?
566 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:mitchell042997
ID: 1272145
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
ID: 1272146
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
ID: 1272147
So what is a user defined type in this case?

Michel
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 

Author Comment

by:gdg60
ID: 1272148
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
ID: 1272149
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
ID: 1272150
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 40 total points
ID: 1272151
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

721 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