Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2004, 02:14 PM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing File numbers

I'm trying to pass a file number from one function to another (so I can open a file in one function and then print to it in another). However I can't seem to find the proper syntax in order to do this.

Any help would be greatly appreciated.
 
Old June 3rd, 2004, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

can you be more explicit??

the file number is just a long, what's the problem with that???

HTH

Gonzalo
 
Old June 3rd, 2004, 02:37 PM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's my calling function code:
ControlFilename = GetTempDir & "\\" & GetControlFilename & ".txt"

Open ControlFilename For Output As #2 Len = 200

How do I pass the #2 to the calling function ? If my calling function is PrintData what would the argument that I pass to it ?

Thanks !
 
Old June 3rd, 2004, 02:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

yourdestfunction (lFileNumber as long)

never use a static file number, better use a variable and get the number for it using
Code:
 
dim nMyFile as long
nMyFile = freefile
from msdn


Returns anInteger representing the nextfile number available for use by the Open statement.

Syntax

FreeFile[(rangenumber)]

Remarks

Use FreeFile to supply a file number that is not already in use



HTH

Gonzalo
 
Old June 3rd, 2004, 04:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

just a clarify: the file number is an interger, not a long.
A better syntax is:

YourDestFunction(byval lFile as Integer)

Marco
 
Old June 8th, 2004, 08:18 AM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

so how do I refer to the passed file number in the called function ?

Usually I use the following syntax: print #2 variable1, variable2

Thanks in advance for the help !
 
Old June 8th, 2004, 08:41 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi again..

print #yourvariable variable1, variable2....

HTH

Gonzalo
 
Old June 8th, 2004, 10:25 AM
Authorized User
 
Join Date: Dec 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks ! That works !





Similar Threads
Thread Thread Starter Forum Replies Last Post
searching a text file for repeated numbers Un33k Visual Basic 2005 Basics 1 October 30th, 2007 01:50 PM
Passing Image File as a parameter MAKO C# 3 October 10th, 2006 12:55 PM
passing parameter to xsl file anandjun XSLT 3 March 24th, 2006 02:46 PM
passing an image file to a .net file. sanjeet .NET Web Services 2 September 22nd, 2005 01:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.