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

x
?
Solved

VBScript code to call a sub in a DLL

Posted on 1999-07-07
11
Medium Priority
?
995 Views
Last Modified: 2013-12-25
I'm using FP2000, PWS w/W98.I want to call a sub (PROB3) in a DLL (MATH.DLL) using VBScript and put a variable generated by the sub (PROBLEM$) into a picturebox (Pbox) on an  ACTIVEX CONTROL (STU.OCX). Could I please see exact VBS Code using the references I put in parentheses. Are there any preliminaries I must do to ensure that the code works? Did I have to do something before I compiled the DLL or before I compiled the OCX re: add properties, methods, events or anything else?
Thanks !!!!
0
Comment
Question by:mathprof
[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
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 1

Accepted Solution

by:
ssite earned 600 total points
ID: 1863834
Unfortunately, VBScript can't call DLL's directly.

What you need to do is this:

In your OCX which you've probably created using VB, define a regular DECLARE statement for the DLL.

Use the DLL internally in the control. If you need to receive parameters from the VBS code, you should implement this as a method in side your OCX.

This way, VBS calls the VB OCX's method and it calls the DLL. You can return results and even set the OCX's properties without even it concerning VBS.
0
 
LVL 6

Expert Comment

by:PBall
ID: 1863835
wrap them up :)

nice thing a wrapper is hehehe.

0
 

Author Comment

by:mathprof
ID: 1863836
You strategy almost works.
My DLL is math.dll my function is
function a101 (byval problem as string)
...
problem$="2+2="
end function
--------------------------

My OCX declare is
private declare function a101 Lib "math.dll" (byval problem as string)
error is: cant find entry point a101 ...
My revised Declare is:
Private declare function a101 Lib "math.dll" alias "#1" (byval problem as string)
no error
my ocx call is call a101
error is: argument not optional
my revised call is: call a101 (byval problem as string)
error is at word 'as': expected list separator or )
my revised call is: acll a101 (by val problem)
error is: runtime error 49 Bad DLL calling convention.
What now ?


0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 1

Expert Comment

by:ssite
ID: 1863837
I need the EXACT code of the DLL. The problem you have is that VB not only recognizes your function properly, it doesn't even recognize the DLL properly.
0
 

Author Comment

by:mathprof
ID: 1863838
How can I send you the code?

0
 

Author Comment

by:mathprof
ID: 1863839
I still am stuck at my call function. The Declare function is: Declare Function a101 Lib "math.dll" (byVal Problem as string) and is OK!!  I do not get an error. It DOES find the DLL. (I am not using alias).
When I run the OCX (design mode) and my call is
Call a101
I get an error at the Call :"Argument NOT optional)
When I start with (, VB suggests and I finish with byval problem as string). Yet when I run I get an error on the word AS "expected list separator or )".
When I Just use call a101 (problem) and run I get error 49 "BAD DLL calling convention."

0
 
LVL 1

Expert Comment

by:ssite
ID: 1863840
You can send me the code (DLL, APP) to ssite@netvision.net.il
0
 
LVL 1

Expert Comment

by:yerffoeg
ID: 1863841
I don't understand why ssite says that you can't call a DLL
function directly. Unless your DLL is not split into class
Modules (hence the Math.class where you don't mention the
class) This is what I do when calling ActiveX DLLs from VBScript.

<%
Dim Problem$

Set ReftoMathDLL = Server.CreateObject("Math.Class")
Problem$ = RefToMathDLL.Prob3("2+2")
%>
0
 
LVL 1

Expert Comment

by:ssite
ID: 1863842
Yes, yerrffoeg, but you are not calling a DLL. You are creating an instance of an ActiveX object which is stored in a DLL. What mathprof wants is to call a regular win32 DLL(which doesn't contain objects, but rather functions).

Oh yeah, can I get my points??
0
 
LVL 1

Expert Comment

by:yerffoeg
ID: 1863843
Oui, Je comprende.
0
 

Author Comment

by:mathprof
ID: 1863844
I'm giving ssite the points. However, I note that inasmuch as I did not receive his offer to look over my code because of a delay in receiving his e-mail, I got help from another source which incorporated his response to yerffoeg's comment.
My dll is:math911.dll
It has a class:questions which has a function: a101
My OCX (stuinput1.ocx) code follows:
'declaration
private objM as Math911.questions

sub geta101()
'create instance (when loading control)
Set onjM= New Math911.questions
'use the function
call onjM.a101(problem)
'the call returns variable:problem
end sub

My webpage code:   call stuinput1.geta101
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

722 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