writing to files

jardini
04-25-2003, 07:36 PM
i can understand how to write to files, but the thing is that i want to write it plain.. when u write a string to a file, it closes it in quotes. i dont want that to happen, becuase when the file is opened in notepad, it has the quotes. is there a way to take the EXACT text from a textbox in the form and write it, and it only, directly to a .txt file??

thanks,
jared

YuanHao
04-25-2003, 07:42 PM
Actually, if you save a string to a text file using input, it does NOt contain the quotes. Quotes means "it's a string". For example:

Dim a as string
a = "This has quotes at the end"
Me.Caption = a

Does the form's caption have quotes at the end? :p

starbitz
04-25-2003, 07:47 PM
Are you using Write #file_num to write text in your text file? If you do and you do it this way:
Write #1, "Johny"
then it will include the quotes, You can use Print #file_num to write the contents of your textbox to your file,like this:
Print #1, texbox.text

jardini
04-25-2003, 08:30 PM
sorry, YuanHao, but thats not what i mean, perhas i was not clear enough... yes, i was using Write#. i will they the other.. thanks!

- jared

jardini
04-25-2003, 08:44 PM
o, one more thing.. is there a way to cut off the new line at the end?

Print #1, "hey"

returns:

"hey
(newline)"




can i cut that off??

thanks,
jared

starbitz
04-25-2003, 10:32 PM
really? weird... :confused:
It should only display hey (no quotes). Can you post part of your code where you call Print # or the part of your code in writing to files?

unclebill
04-25-2003, 10:34 PM
o, one more thing.. is there a way to cut off the new line at the end?

Print #1, "hey"

returns:

"hey
(newline)"




can i cut that off??

thanks,
jaredPrint #1, "hey";

jardini
04-25-2003, 10:59 PM
the quote problem is fixed, but it has the new line. i understand that visual basic automatically adds a new line to the output, but is there a way to stop it?

- jared

zizdodrian
04-25-2003, 11:56 PM
Maybe you should use FileSystemObject

Dim f As New Scripting.FileSystemObject
Dim fs As f.CreateTextFile
f.WriteAll Text1.Text
Close f

I think thats right anyway... ;)

unclebill
04-26-2003, 11:02 AM
the quote problem is fixed, but it has the new line. i understand that visual basic automatically adds a new line to the output, but is there a way to stop it?

- jaredIf your print statement has a semicolon [;] at the end, the newline characters are suppressed. Try this code for a test of the output.Private Sub Form_Activate()
Open "C:\TempTest.txt" For Output As #1
Print #1, "This is my test string! - ";
Print #1, "This is my test string!"
Close #1
End SubWhen you open the file in notepad, you'll find both pieces of text on the same line and a CR/LF at the end of the file.

zizdodrian
05-01-2003, 12:44 AM
Thats the same with QBasic, for anyone who knows it.

unclebill
05-01-2003, 10:00 AM
Thats the same with QBasic, for anyone who knows it.That goes all the way back to Interpretive BASIC Level I and Level II as found on the Radio Shack Model I computers c. 1978 and I suspect before that.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum