NewB question about VB variable passing

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
TommyJ
Newbie
Posts: 11
Joined: Tue Sep 30, 2003 8:59 pm

NewB question about VB variable passing

Post by TommyJ » Thu Mar 11, 2004 2:38 pm

In VB I want to connect to an Access database and get the values from a given recordset, I want to then pass these values out of VB into the regular scheduler routine. Then I loop back into Access and go to the next recordset, do the same thing again, until rst.EOF

I can write the code to connect to the database and pass the recordset to vb variables, but how do i use those values outside of the vb and then loop back in?

(sorry I don't have sample code, I'm not sure where to start until I get this variable passing figured out)

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Mar 11, 2004 5:46 pm

Passing variables into VBScript is done in one of two ways:

VBRun>VBScriptSubRoutine,parameter1,parameter2,.....

VBEval>VBScriptFunction(parameter1,parameter2,..),resultvar

With VBEval when sending strings remember that VBScript requires strings in quote marks, so you will need to do this:

VBEval>VBScriptFunction("%parameter1%","%parameter2%",numericval,..),resultvar

To pass variables back they will need to be returned by VBScript functions. The result of the vbscript function above is transfered into resultvar.

Looping through recordsets I would suggest you write a VBScript Function which takes a record number as a parameter, gets the data and returns the record as a semicolon delimited string. Then you can control the loop in MacroScript calling the VBscript function for each record and using Separate to parse the results to split into individual elements. Make the return value EOF or something when it reaches the end and test for this in the MacroScript controlling routine.

This is preferable to having the VBscript function read the entire recordset as passing such a large variable or set of variables back to MacroScript would be tricky.
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts