Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Do i need a close at the end of this code???

Do i need a close at the end of this code???

Scheduled Pinned Locked Moved Visual Basic
csharpjavascriptlinuxtools
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Support123
    wrote on last edited by
    #1

    Hi, I just want to know if it would be advised to put the following at the end of this code: Set objFSO = CreateObject("Scripting.FileSystemObject") Set objOutFile = objFSO.OpenTextFile("\\jhbtest01\e$\SARS\Script\FileWithFilePath\FileNameFormA.txt", 2, True) strLine = FileName objOutFile.WriteLine strLine Should i add this at the end: objOutFile.Close AND is this the right way of doing the close section??? (it is working without it but i get error... so it works the first time round but fails second time round... without me seeing the error.)... Oh yeah... this bit of code is in a javascript file that i call through VB.Net using the Shell()

    "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

    D 1 Reply Last reply
    0
    • S Support123

      Hi, I just want to know if it would be advised to put the following at the end of this code: Set objFSO = CreateObject("Scripting.FileSystemObject") Set objOutFile = objFSO.OpenTextFile("\\jhbtest01\e$\SARS\Script\FileWithFilePath\FileNameFormA.txt", 2, True) strLine = FileName objOutFile.WriteLine strLine Should i add this at the end: objOutFile.Close AND is this the right way of doing the close section??? (it is working without it but i get error... so it works the first time round but fails second time round... without me seeing the error.)... Oh yeah... this bit of code is in a javascript file that i call through VB.Net using the Shell()

      "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Support123 wrote:

      Should i add this at the end: objOutFile.Close

      Yeah, that would probably be a good idea.

      Support123 wrote:

      it is working without it but i get error...

      And that error would be ....??

      Support123 wrote:

      so it works the first time round but fails second time round...

      This is probably because you didn't close the file and are trying to open it again.

      Support123 wrote:

      this bit of code is in a javascript file

      No, it's not. This is code snippet you posted is VBScript.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      S 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Support123 wrote:

        Should i add this at the end: objOutFile.Close

        Yeah, that would probably be a good idea.

        Support123 wrote:

        it is working without it but i get error...

        And that error would be ....??

        Support123 wrote:

        so it works the first time round but fails second time round...

        This is probably because you didn't close the file and are trying to open it again.

        Support123 wrote:

        this bit of code is in a javascript file

        No, it's not. This is code snippet you posted is VBScript.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        S Offline
        S Offline
        Support123
        wrote on last edited by
        #3

        Support123 wrote: this bit of code is in a javascript file No, it's not. This is code snippet you posted is VBScript. sorry about that... i was thinking one thing and writing another. I had a java question too (i am working on a ssis project and asp.net project so i messed up the question). i appologize and thank you for the info. I will add the objOutFile.Close() section to the VBSript. (i dont know what the error is exactly... it is not displaying anything of use... it is saying that i have issues in one of my script files (vb.net) in the ssis package but it is working fine through visual studio... Only a problem when it is ran through a job in sql, so i thought that maybe the VBScript needed to be tweeked a bit.) I will test to see if it works. Thank you for your time.

        "Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups