writing and reading from file
Posted on 2002-05-13
I have this few names. When i read it using Open "c"\product.dat" for input as #FileNum,
the first word Adobe Photoshopv_1 have something like this: "ybAdobe Photoshopv_1". Why is this so???
i suspect this to be linefeed or something like that. how to get rid??? Adobe Photoshopv_1 is the
first name on the product.dat file.
Another problem is when i tried to UPDATE Macromedia Freehandv_3 to Macromedia Freehandv_4,
it becomes like this:
Macromedia Freehand‰C⁁—ð¶Ø°T⸲⸶v_4romedia Fireworkv_2
The line Macromedia Freehandv_4 is somehow updated but there is lot of ⸶ char and
part of the word Macromedia Firewordv_2 is lost somehow.
The code is like this:
Dim sEmptyStr, sPosition
versionUpdate= "Macromedia Freehandv_4"
nameoffile = "Macromedia Freehand"
FileNum = FreeFile()
Open "C:\product.dat" For Input As #FileNum
Do Until EOF(FileNum)
Line Input #FileNum, newline
test = InStr(newline, nameoffile)
'get the position of the line
sPosition = Seek(FileNum) - Len(newline) - 2
sEmptyStr = Space(Len(versionUpdate)) 'Line's length
Open "C:\product.dat" For Binary Access Write As #FileNum
Put #1, sPosition, sEmptyStr
Put #FileNum, sPosition, nameUpdate