Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 70
How to compare ms sql hashbytes results within vb6 5 73
How to make an ADE file by code? 11 83
Child Form in front 4 46
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

776 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