Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > File I/O and Registry > Data Format when writting to a text file


Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2004, 09:30 AM
drumgod drumgod is offline
Regular
 
Join Date: Nov 2003
Posts: 69
Question Data Format when writting to a text file


All,

I have a program that will write data to a text file, then read the text file and load the data into textboxes on my form. Problem i have is when the data is written to the text file, it is put in quotes, and loaded with the quotes. I need to be able to save the data to a text file with out quote. Here is my code:



Private Sub Command1_Click()
Dim strFile As String
Dim Program_Name As String

strFile = App.Path & "\inidata.ini"

Call dhWriteAndInput(strFile)
End Sub

'--------------------------------------------------------------

Private Sub dhWriteAndInput(strFile As String)
On Error GoTo ErrorHandler

Dim hFile As Long
ReDim varData(1 To 5) As Variant
Dim i As Integer

'Open a file for output, write to it and close it
hFile = FreeFile

Open strFile For Output Access Write As hFile
Write #hFile, Text1.Text
Write #hFile, Text2.Text
Close hFile

'Now open it back up for reading
hFile = FreeFile
Open strFile For Input Access Read As hFile
Input #hFile, varData(1), varData(2), varData(3), varData(4), varData(5)
Close hFile

ErrorHandler:
Select Case Err.Number ' Evaluate error number.
Case 53 ' "File NetManage.ini does not exist on C:\"
MsgBox "File NetManage.ini does not exist on C:\"
Case 55 ' "File already open" error.
Close #1 ' Close open file.
Case Else
' Handle other situations here...
End Select

Resume Next
End Sub

My text file content will look like this when completed.

"text1"
"text2"

How do i get it to look like this ? (With out quotes)

text1
text2

TIA

Drum
Reply With Quote
  #2  
Old 01-28-2004, 10:45 AM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

If you don't want the quotes, use "Print #" instead of "Write #".
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 01-30-2004, 01:30 AM
RoofRabbit's Avatar
RoofRabbit RoofRabbit is offline
Contributor
 
Join Date: Sep 2003
Location: Lenoir, NC - USA
Posts: 731
Default

Or just use Put#
Reply With Quote
  #4  
Old 01-30-2004, 06:33 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

Put # would only work if the file was open for Binary or Random, not Output.
Put #, will also write numeric type numbers as a binary image and would
not be readable as a text file.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
File I/O GavinO Tutors' Corner 5 04-17-2013 01:18 PM
Installation Problem - PLs help urgenlty dpdsouza Installation / Documentation 4 12-02-2004 07:09 PM
File Server Pointer Issues Alpha_7 Communications 3 10-03-2003 10:11 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->