Sorry about the typo in "Option Explicit" there.  Should be all on one line of 
course.

--- In [email protected], "michiman56" <rriemer...@...> wrote:
>
> 
> Ok, it looks like you are using the newObjects SFMain to do this.  I'm
> not a fan of using magic numbers, even if they do save space in NSB/CE
> programs.  I always have to look them up, so I prefer to declare
> constants using the names in the library's typelib where possible.
> 
> You seem to be opening the same file twice for some reason.  Once as
> outFile and again as file2.  That might be why you're seeing the results
> you experience.
> 
> Here's an example that works for me:
> 
> Option Explicit
> 'newObjects SFMain flags/values ----------------------
> 'Open/create mode flags.
> Const cSFRead = &H0
> Const cSFWrite = &H1
> Const cSFReadWrite = &H2
> 'Sharing.
> Const cSFShareExclusive = &H10
> Const cSFShareDenyWrite = &H20
> Const cSFShareDenyRead = &H30
> Const cSFShareDenyNone = &H40
> 'Creation specific (these apply to CreateXXX methods).
> Const cSFFailIfThere = &H0
> Const cSFCreate = &H1000 'Create/overwrite.
> 'WriteText options.
> Const cOptChars = 0
> Const cOptLine = 1
> 'Seek origins.
> Const cStreamBegin = 0
> Const cStreamCurrent = 1
> Const cStreamEnd = 2
> 
> Dim SFM, stmTextFile
> Const FILENAME = "\Documents and Settings\TestText.txt"
> 
> Set SFM = CreateObject("newObjects.utilctls.SFMain") 'Or use AddObject.
> Set stmTextFile = _
>      SFM.CreateFile(FILENAME, cSFWrite Or cSFShareExclusive Or cSFCreate)
> With stmTextFile
>      .WriteText "Line 1", cOptLine
>      .WriteText "Line 2", cOptLine
>      .WriteText "Line 3", cOptLine
>      .Close
> End With
> MsgBox "New file 3 lines", vbOKOnly, "TextFileProg"
> 
> Set stmTextFile = SFM.OpenFile(FILENAME, cSFReadWrite Or
> cSFShareExclusive)
> With stmTextFile
>      .Seek 0, cStreamEnd
>      .WriteText "Line 4", cOptLine
>      .WriteText "Line 5", cOptLine
>      .WriteText "Line 6", cOptLine
>      .Close
> End With
> MsgBox "Added 3 more lines", vbOKOnly, "TextFileProg"
> 
> Set stmTextFile = _
>      SFM.CreateFile(FILENAME, cSFWrite Or cSFShareExclusive Or cSFCreate)
> With stmTextFile
>      .WriteText "New Line A", cOptLine
>      .WriteText "New Line B", cOptLine
>      .Close
> End With
> MsgBox "New new file 2 lines" & vbNewLine & "Done!", vbOKOnly,
> "TextFileProg"
> 
> Bye
> 
> 
> --- In [email protected], "georgeewalters" <gwalters@>
> wrote:
> >
> > Here is the code:
> >
> > outName = "\Documents and Settings\AcuTrack\StockCount.txt"
> >
> > Set outFile = fs.CreateFile(outName, 4096)'--Create and open and
> > Set file2 = fs.OpenFile(outName)
> > For i = 1 To count
> > tmp = list(i,0) & list(i,1) & list(i,2) & list(i,3)
> > MsgBox tmp
> > file2.WriteText tmp
> > Next
> >
> > file2.Close
> >
> > MsgBox("File saved")
> >
> > My understanding is the CreateFile with 4096 will delete the file if
> it exists and create a new empty file. I then write one record to the
> file and when I look at the file with fileExplorer (on PDA i'm talking)
> it has the record I wrote but at end of all the other records. So the
> createfile did not delete the file. Can someone explain? I must be
> understanding something wrong or a mistake in the code above.
> >
> > Flags are:
> >
> > 0 - Fail if file already exists (default)
> > 4096 - If file exists, delete and recreate
> >
>


-- 
You received this message because you are subscribed to the Google Groups 
"nsb-ce" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nsb-ce?hl=en.

Reply via email to