Re: help..where have i gone wrong in this code?
> Dim changedfile As Integer
> tchangedfile = FreeFile
> Open "c:\ammended..txt" For Output As changedfile
> Print #changedfile, changedstring
> Close changedfile
Jaffer: Was the code you posted cut-and-pasted from your application? If so,
the problem may be that your output file handle is named "changedfile", but
you're assigning the result of FreeFile to a variable named "tchangedfile".
Also, I'm not sure what effect, if any, having two periods in the file name
"c:\ammended..txt" might have.
A couple of suggestions: make sure you have "Option Explicit" specified at
the top of your module; this will catch any errors caused by misspelled
variable names. Also, when you post code to a newsgroup, always
cut-and-paste actual code from your project, to eliminate the possibility of
help..where have i gone wrong in this code?
I am trying to create a code that will edit a line in my text file. The
logic i have used it to get the whole file in a string, use replace to make
the changes to the point which i want to edit. The changes then are stored
in a new string, which uses output to another file. I have written the code,
but need your help, coz the changed string is not gettting written in the
file..here is the code..
Dim FF As Long
Dim Quote1 As Long
Dim Quote2 As Long
Dim Position As Long
Static FileContents As String
FF = FreeFile
Open "c:\original.txt" For Input As #FF
FileContents = vbNewLine & Input(LOF(FF), #FF)
Position = InStr(FileContents, vbNewLine & Text1.Text)
Quote1 = InStr(Position, FileContents, """")
Quote2 = InStr(Quote1 + 1, FileContents, vbCrLf)
linestring = Mid$(FileContents, Quote1, _
Quote2 - Quote1)
changedstring = Replace(FileContents, linestring, "GOOGLE")
Dim changedfile As Integer
tchangedfile = FreeFile
Open "c:\ammended..txt" For Output As changedfile
Print #changedfile, changedstring
Any idea why wouldnt the file ammended.txt be created?..its not giving me
any errors as well.....The file original.txt is in the folowing format
abc password="abc", lastname = "xyz"
jay password="txw" lastname="donald"
The string linestring containts each line in the file.
Any idea, pls help...thanks!
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL