[AccessD] Iteration construct to print variables

Stuart McLachlan stuart at lexacorp.com.pg
Tue Mar 11 17:03:01 CST 2003


That's what arrays are for.

Dim lngTemp(20) as Long
Dim lngCounter as Long
...

For lngCounter = 1 to 20
Print #1, lngTemp(lngCounter)
Next


> List,
> 
> I'm doing an output to file routine in a module. 
> 
> I have a number of variables dimmed as long -- c1, c2, c3, c4, ... c20 
> 
> The data file is required to put each data field on a separate line:
> 	tDate
> 	c1
> 	c2
> 	...
> 	c20
> 
> My data is a single recordset of a query. I make a number of calculations
> and then output all the  results:
> 
> 	c1 = rst!FieldOne
> 	c2 = rst!FieldTwo
> 	c3 = rst!FieldThree
> 	c4 = c1 + c2 + c3
> 	...
> 	Print #1, c1
> 	Print #1, c2
> 	Print #1, c3
> 	Print #1, c4
> 	...
> 
> It seems to be inefficient to have 20 lines of "Print #1, c..." Is there a
> way I could run a loop something like?
> 
> 	For i = 1 to 20
> 		Print #1, "c" + i
> 	Next i
> 
> I know that specifically won't work as I tried it, but I hope you can see
> what I'm driving at. I would like to loop through variables (c1...c20) and
> do a Print# for each.
> 
> Thanks for your help,
> 
> Bob Geldart
> RGeldart at detma.org
> Massachusetts Department of Employment & Training
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com


-- 
Lexacorp Ltd
http://www.lexacorp.com.pg
Information Technology Consultancy, Software Development,System Support.






More information about the AccessD mailing list