Solved

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

Posted on 2004-09-24
3
193 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

12 Experts available now in Live!

Get 1:1 Help Now