Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Appending to .txt File

Status
Not open for further replies.

LuckyDuck528

Programmer
Dec 21, 2004
65
US
Hello,

This will probably be easy for some of you seasoned coders but I am still quite new at working w/ VB and could use some help figuring out my problem.

I have a file that is created the first time this program is run and everytime after that it is just appended to.

The problem is, my code doesn't append. I get an error and the .exe program quits.

Also, does anyone know how I can separate my values with a ","? I would like to be able to open this comma delimited file in excel at a later time.

Thank you for your help. It is sincerely appreciated. Have a great day!

Code:
Const strMasterLogFile = "D:\data\temp_files\deploy\archive\MasterLogFile.txt"

(..other code...)

If objFSO.FileExists(strMasterLogFile) Then
    Open strMasterLogFile For Append As #10
        Print #10, strServerName; strUsername; strFileName; strFilePath; strComments
    Close #10
Else
    Open strMasterLogFile For Output As #10
       Print #10, "Server,User Name,File Name,Path,Comments"
       Print #10, strServerName; strUsername; strFileName; strFilePath; strComments
      Close #10
End If

(more code...)
 
I'm sorry, nevermind this one. It only won't work when I am trying to work on a remote server... Thus must be a different problem...

Thanks though!!
 
You could use join:

Dim MyString
Dim MyArray(4)
MyArray(0) = strServerName
MyArray(1) = strUsername
MyArray(2) = strFileName
MyArray(3) = strFilePath
MsgBox Join(MyArray, ",")

Swi
 
You could use join:

Dim MyArray(4)
MyArray(0) = strServerName
MyArray(1) = strUsername
MyArray(2) = strFileName
MyArray(3) = strFilePath
MsgBox Join(MyArray, ",")

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top