?
Solved

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

Posted on 2004-09-24
3
Medium Priority
?
200 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 400 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 1600 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

770 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