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)
NewB question about VB variable passing
Moderators: Dorian (MJT support), JRL
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.
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]
[email protected]