Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it possible to use a variable in place of #1?

    I need to print to various files; passing a variable makes sense to me.

    [codebox]outfile = "c:\text.txt"
    Open outfile For Output As #1
    Print #1, "mytext out"
    Close #1

    Example passing a variable:
    oVar = 1
    outfile = "c:\" & oVar &".txt"
    Open outfile For Output As #oVar
    Print #oVar, "mytext out"
    Close #oVar
    [/codebox]


    Regards,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Yes, that should work. The variable needs to be of type Integer.

  3. #3
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='jstevens' post='774512' date='10-May-2009 01:08']Is it possible to use a variable in place of #1?[/quote]
    Hi John
    Are you aware of the FreeFile function, explained here.
    Regards
    Don

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    FreeFile is a useful function, but John wants to use the variable in the filename too, so FreeFile might not quite suit his purpose.

  5. #5
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='774551' date='10-May-2009 11:13']FreeFile might not quite suit his purpose.[/quote]

    Point taken.
    Regards
    Don

  6. #6
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wendle,

    Thanks for the link for FreeFile: I was unaware of it. I may have a use for it in another project I am working on.

    Regards,
    John

    [quote name='wdwells' post='774537' date='10-May-2009 05:49']Hi John
    Are you aware of the FreeFile function, explained here.[/quote]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •