|
-
Dec 17th, 2008, 04:14 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Unwanted " when writing to file
Hi i have a small problem when writing to a file, it writes unwanted " at the begining and end.
vb Code:
Private Sub Command1_Click()
Dim str As String
str = "[Test]" & vbNewLine & "S0=ftp.mysite.com" & vbNewLine & "S1=grabs" & vbNewLine & " [email protected]" & vbNewLine & "S3=password" & vbNewLine & "S4=http://www.mysite.com/grabs/"
Open App.Path & "\settings.ini" For Output As #1
Write #1, str
Close #1
End Sub
the output is
Code:
"[Test]
S0=ftp.mysite.com
S1=grabs
[email protected]
S3=password
S4=http://www.mysite.com/grabs/"
when is should be
Code:
[Test]
S0=ftp.mysite.com
S1=grabs
[email protected]
S3=password
S4=http://www.mysite.com/grabs/
Does anyone have a soloution? Thanks
-
Dec 17th, 2008, 04:17 PM
#2
Re: Unwanted " when writing to file
Write to the file like this:
vb Code:
Open App.Path & "\settings.ini" For Binary Access Write As #1 Put #1, , str Close #1
[Edit]
Why aren't you using WritePrivateProfileString API to write to the INI file ?
Last edited by CVMichael; Dec 17th, 2008 at 04:21 PM.
-
Dec 17th, 2008, 04:22 PM
#3
Thread Starter
Addicted Member
Re: Unwanted " when writing to file
Thanks that works for the last " but the begining is still weird, looks like this.
Code:
e [Test]
S0=ftp.mysite.com
S1=grabs
[email protected]
S3=password
S4=http://www.mysite.com/grabs/
-
Dec 17th, 2008, 04:27 PM
#4
Thread Starter
Addicted Member
Re: Unwanted " when writing to file
Nevermind i figured it out thanks just did
vb Code:
Open App.Path & "\settings.ini" For Output As #1 Print #1, str Close #1
-
Dec 17th, 2008, 04:27 PM
#5
Re: Unwanted " when writing to file
If I use the same code you are using, I am not getting that stuff at the beginning... are you sure that's the only code you are using ?
This usually happens when you save a data type other than string (like Variant).
Also, try deleting the file if it's already there, then run your code...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|