home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1710
Discussions: 188,401, Posts: 2,243,608, Members: 232,631
Old August 24th, 2005, 05:13 AM   Digg it!   #1 (permalink)
Member
 
Acid_ICE24's Avatar
 
Join Date: Jul 2005
Location: Cavite, Phil.
Posts: 94
Question
How to create, edit, and delete a text file using Visual Basic 6?

hi pips!

i'm working on a vb6 project right now and there's a part in it where i need to create a log file. anybody knows how 2 create a text file and then later on, edit or delete it?

i made some research and this is what i produced, so far:

Sub GenerateLog(vValue As Variant, sField As String)
Dim iFileNumber As Integer
Static iErrCtr As Integer

iErrCtr = iErrCtr + 1

iFileNumber = FreeFile
Open App.Path & "\HCFA_LOG.txt" For Append As #iFileNumber

If bLogCreated = False Then
Write #iF
ileNumber, "DATE: " & Format(Date, "MM/dd/yyyy")
Write #iFileNumber, "TIME: " & Format(Time, "hh:mm AMPM")
Write #iFileNumber,
Write #iFileNumber,
End If

bLogCreated = True

Write #iFileNumber, "Error #: " & iErrCtr
Write #iFileNumber, "GUID: " & sDocGUID

Write #iFileNumber, "Error in field: '" & sField & "'"
Write #iFileNumber, "Data: " & vValue
Write #iFileNumber,

Close #iFileNumber
End Sub

this works fine but i don't really like how the output looks (notice the quotation marks?). and everytime i call this sub, it doesn't overwrite the old one.

any kind of help is welcome.... thanks!
Attached Files
File Type: txt HCFA_LOG.txt (1.3 KB, 1371 views)
__________________
keep 'em comin...

Acid_ICE24 is offline   Reply With Quote
Old August 25th, 2005, 12:26 AM     #2 (permalink)
Member
 
Acid_ICE24's Avatar
 
Join Date: Jul 2005
Location: Cavite, Phil.
Posts: 94
anybody?

Acid_ICE24 is offline   Reply With Quote
Old August 26th, 2005, 01:13 PM     #3 (permalink)
Banned
 
Iturea's Avatar
 
Join Date: Jan 2004
Location: Earth
Posts: 420

Iturea is offline   Reply With Quote
Old August 27th, 2005, 03:08 AM     #4 (permalink)
Member
 
Acid_ICE24's Avatar
 
Join Date: Jul 2005
Location: Cavite, Phil.
Posts: 94
hey, thanks! :-)
Acid_ICE24 is offline   Reply With Quote
Old August 14th, 2008, 05:27 AM     #5 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 1
Lightbulb

Ahh, I recently had the same problem as you, but in reverse.

I wanted to add data to my file every time, without overwriting what data already existed, as I was making a highscores list.

I was using the "OUTPUT" command instead of the "APPEND". If you're making a log file, you want the "OUTPUT" command. Just replace the word "APPEND" with "OUTPUT".

However, for the output command, your log file, HCFA_LOG.txt will need to already exist. If this is a problem, then perhaps you could use APPEND but also use the "kill" command to delete your text file upon opening your program each time?

EDIT: Oh yeah, and if you don't like the look of that the "write" command produces, use the "print" command in place of it. The print command doesn't store any data about strings or variables of any kind, so there are no quotations to separate variables. So, if it's just for the sake of its looks, use print.

Last edited by kid_headshot : August 14th, 2008 at 05:31 AM. Reason: Adding more to my answer
kid_headshot is offline   Reply With Quote
Reply


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

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Help? redfoxstorm Webmastering and Programming 1 February 14th, 2005 11:39 AM
HELP!! - Visual Basic darssus Webmastering and Programming 1 October 6th, 2004 02:40 PM
Scan Text (Visual Basic .NET question) firewolf Applications and Operating Systems 2 October 4th, 2003 03:23 PM
Visual Basic .Net - DLL file question firewolf Applications and Operating Systems 15 September 17th, 2003 11:25 PM
Visual Basic HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!! George VII Webmastering and Programming 8 May 18th, 2002 06:46 PM

Most Active Discussions
Is It Just Me? (2906)
3-days in and no threads about Gaza (161)
Unarmed man on his stomach shot by .. (6)
New Build ( Finally ) (7)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
RCA 52Inch HDTV wont turn on (5)
Folderchat Weekday thread (444)
Recent Discussions
Laptop proccesor to desktop mob.. (2)
Please help! multiple problems! (4)
RCA 52Inch HDTV wont turn on (5)
New Build ( Finally ) (7)
Common Spyware Solutions (97)
How do you move a hard-drive to.. (4)
What is the best external enclo.. (0)
Partition Magic 7.0 (Unallocate.. (17)
For cheap price and good qualit.. (1)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 04:12 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28