Text Files

0 pts.
Tags:
Development
Hi. I am a little lost, and have a VB 6 problem. I need to write a text string to a file, but need it to be in a text file format without the "" around the string. Is there a way that you can get VB to write the file this way?
ASKED: November 10, 2004  2:41 AM
UPDATED: November 11, 2004  10:08 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

if you write a text in a file with vb like with a print #1, text$ , there is no ” add around the string text .
if you want to put some ” in the text you must add some chaine characters like toto$ & chr(34) & titi$

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Rowena
    I found this in VB help or on the web one...i don't remember. The Submit_Click sub actually does the writing to the file and the file does not have any quotation marks. Imports System Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Submit As System.Windows.Forms.Button Friend WithEvents Clear As System.Windows.Forms.Button Friend WithEvents Entry As System.Windows.Forms.TextBox Friend WithEvents DisplayEntry As System.Windows.Forms.TextBox Friend WithEvents Display As System.Windows.Forms.Button Friend WithEvents GetEntries As System.Windows.Forms.Button Friend WithEvents PickEntries As System.Windows.Forms.ComboBox Private Sub InitializeComponent() Me.Submit = New System.Windows.Forms.Button Me.Clear = New System.Windows.Forms.Button Me.Entry = New System.Windows.Forms.TextBox Me.DisplayEntry = New System.Windows.Forms.TextBox Me.Display = New System.Windows.Forms.Button Me.GetEntries = New System.Windows.Forms.Button Me.PickEntries = New System.Windows.Forms.ComboBox Me.SuspendLayout() ' 'Submit ' Me.Submit.Location = New System.Drawing.Point(16, 40) Me.Submit.Name = "Submit" Me.Submit.Size = New System.Drawing.Size(96, 23) Me.Submit.TabIndex = 0 Me.Submit.Text = "Submit Entry" ' 'Clear ' Me.Clear.Location = New System.Drawing.Point(176, 40) Me.Clear.Name = "Clear" Me.Clear.Size = New System.Drawing.Size(96, 23) Me.Clear.TabIndex = 1 Me.Clear.Text = "Clear Entry" ' 'Entry ' Me.Entry.Location = New System.Drawing.Point(8, 16) Me.Entry.Name = "Entry" Me.Entry.Size = New System.Drawing.Size(272, 20) Me.Entry.TabIndex = 2 Me.Entry.Text = "Please enter something" ' 'DisplayEntry ' Me.DisplayEntry.Location = New System.Drawing.Point(16, 192) Me.DisplayEntry.Multiline = True Me.DisplayEntry.Name = "DisplayEntry" Me.DisplayEntry.Size = New System.Drawing.Size(264, 60) Me.DisplayEntry.TabIndex = 3 Me.DisplayEntry.Text = "Please enter something" ' 'Display ' Me.Display.Location = New System.Drawing.Point(16, 112) Me.Display.Name = "Display" Me.Display.Size = New System.Drawing.Size(96, 23) Me.Display.TabIndex = 4 Me.Display.Text = "Show Entries" ' 'GetEntries ' Me.GetEntries.Location = New System.Drawing.Point(128, 112) Me.GetEntries.Name = "GetEntries" Me.GetEntries.Size = New System.Drawing.Size(96, 23) Me.GetEntries.TabIndex = 5 Me.GetEntries.Text = "Get Entries" ' 'PickEntries ' Me.PickEntries.Enabled = False Me.PickEntries.Location = New System.Drawing.Point(144, 152) Me.PickEntries.Name = "PickEntries" Me.PickEntries.Size = New System.Drawing.Size(121, 21) Me.PickEntries.TabIndex = 6 Me.PickEntries.Text = "Select an Entry" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 273) Me.Controls.Add(Me.PickEntries) Me.Controls.Add(Me.GetEntries) Me.Controls.Add(Me.Display) Me.Controls.Add(Me.DisplayEntry) Me.Controls.Add(Me.Entry) Me.Controls.Add(Me.Clear) Me.Controls.Add(Me.Submit) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click Dim fw As StreamWriter Dim ReadString As String If (Entry.Text = "" Or Entry.Text = "Please enter something.") Then Entry.Text = "Please enter something." Return End If Try 'Pass the file path and name to the StreamWriter constructor. 'Indicate that Append is True, so file will not be overwritten. fw = New StreamWriter("C:MyDiary.txt", True) Dim Today As DateTime Today = Now.ToString fw.Write(CStr(Today)) fw.Write(ControlChars.CrLf) ReadString = Entry.Text fw.WriteLine(ReadString) Finally 'Close the file. fw.Close() End Try End Sub Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear.Click Entry.Text = "" End Sub Private Sub GetEntries_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetEntries.Click Dim fr As StreamReader Dim FileString As String FileString = "" Try fr = New StreamReader("C:MyDiary.txt") PickEntries.Items.Clear() PickEntries.Enabled = True Do FileString = fr.ReadLine If IsDate(FileString) Then PickEntries.Items.Add(FileString) End If Loop Until (FileString Is Nothing) Finally fr.Close() End Try PickEntries.Enabled = True End Sub Private Sub Display_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Display.Click Dim fr As StreamReader Dim FileString As String FileString = "" Try fr = New StreamReader("C:MyDiary.txt") DisplayEntry.Text() = FileString Do FileString = fr.ReadLine If IsDate(FileString) Then PickEntries.Items.Add(FileString) End If If Not (FileString Is Nothing) Then DisplayEntry.Text() = DisplayEntry.Text() + " " + FileString + ControlChars.CrLf End If Loop Until (FileString Is Nothing) Finally fr.Close() End Try PickEntries.Enabled = True End Sub End Class Hope this helps!
    30 pointsBadges:
    report
  • NetAtWork
    "Simplify, Simplify." - Henry David Thoreau This will put without quotes Open "test.txt" For Append As #1 Print #1, Now & ":" & Text2.Text Close #1 This will put in quotes. Open "test.txt" For Append As #1 Write #1, Now & ":" & Text2.Text Close #1
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following