VBScript code to call a sub in a DLL

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 !!!!
mathprofAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ssiteCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PBallCommented:
wrap them up :)

nice thing a wrapper is hehehe.

0
mathprofAuthor Commented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

ssiteCommented:
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
mathprofAuthor Commented:
How can I send you the code?

0
mathprofAuthor Commented:
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
ssiteCommented:
You can send me the code (DLL, APP) to ssite@netvision.net.il
0
yerffoegCommented:
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
ssiteCommented:
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
yerffoegCommented:
Oui, Je comprende.
0
mathprofAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.