rj487
rj487

Reputation: 4634

Write file into txt in VB6

Here is the way how I write file into txt

Dim FileName As String
FileName = "C:\Users\Coda\Desktop\Calendar\file\" & clickDate & ".txt"
Dim Str1 As String, Val1 As Long
Open FileName For Output As #1
   Str1 = Text1.Text
   MsgBox ("Save")
   Write #1, Str1
Close #1

But it automatically add quote in the beginning and end. Like this

"Test1 
Test2 
Test3"

Is there any way I can get rid of these quotes?

Upvotes: 2

Views: 9247

Answers (1)

help-info.de
help-info.de

Reputation: 7298

The short story - use Print instead of Write.

The Write # statement is used to write records with comma-delimited fields to a sequential file. The Write # statement will automatically enclose string fields in quotes and date fields in pound signs.

The Print # statement is used to write formatted strings of data to a sequential file.

To create records in the fixed-width format, you may use following code sample e.g.:

Print #intFooBar, strEmpName; Tab(21); Format$(intDeptNbr, "@@@@"); _
Tab(30); strJobTitle; _
Tab(51); Format$(dtmHireDate, "m/d/yyyy"); _ 
Tab(61); Format$(Format$(sngHrlyRate, "#0.00"), "@@@@@")

Upvotes: 5

Related Questions