Solved

How do I call a sub within a DLL from a VbScript?

Posted on 2004-09-24
3
199 Views
Last Modified: 2010-05-02
Ok, I have tried, but I can't get away from all my errors, and I think posting those is making it worse, So please, will soemone tell me the correct way to call a sub in a DLL from a VBScript.

I am not wroking on a web page, I have written all our file transfer scripts into a DLL because I was asked to.  Now in order to run just the one specified program, and not all 64 programs contained wtihint the DLL I need to call teh main function.  

The Project and DLL are named DCSJobs
The Module wtihin the DLL that contains the sub I am calling is Main
The sub I am calling is named Main_CISPAYPX

I am not even going to post what I wrote cause I don't want tot confuse things.
I have never worked with VBScript before, I have been trying to search and find out how to do this, but all I get is errors.  Please help, and please remember I do not know how to work with VB script at all, so please don't assume I know anything :-).
0
Comment
Question by:Wonderflub
[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
  • 2
3 Comments
 
LVL 26

Assisted Solution

by:EDDYKT
EDDYKT earned 100 total points
ID: 12145758
If you call from VBS make sure all the in and out parameters MUST be declare as variant



ie


public function aa(b as variant, v as variant) as variant
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 12145774

I meant only OUT parameters, not in
0
 
LVL 4

Accepted Solution

by:
avi247 earned 400 total points
ID: 12145862
I am calling the CreateTextFile function of the Scripting dll, File System ObjectClass. Copy and paste this code in Notepad. Rename the file to <filename>.vbs

VBS sends and receives all parameters as Variant types. Hence, as EDDYKT mentioned, the receiving DLL Method would need its parameters as Variant.
--------------------------------------------------------------------------------------------

Dim fso
Dim f1
Msgbox("Starting")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\Scan.txt", True)
f1.WriteLine("Hello world")
f1.Close
Msgbox("Ending")
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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