CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Save My file

  1. #1
    Join Date
    Feb 2000
    Posts
    4

    Save My file

    I'm looking 4 a way to save my file in my program.
    How ca&n I say : Create a new file, and write this and this at this place?
    Or open this file and read this this and this?

    thanx


  2. #2
    Guest

    Re: Save My file

    to write to a ".txt" file and make sure theres a folder called whatever:
    open "c:\whatever\whatever.txt" for output as #1
    write #1, text1
    'if it says variable required, do this:
    open "c:\whatever\whatever.txt" for output as #1
    text1 = line
    write #1, line
    close #1
    ' make sure theres a textbox called text1 on your form


  3. #3
    Join Date
    Feb 2000
    Location
    garden grove, california
    Posts
    64

    Re: Save My file

    i will talk to you in like 5 hours, and give you answer to reading the file


  4. #4
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Save My file

    I like to use the Scripting library for this:

    Dim oFS as Scripting.FileSystemObject
    Dim oStream as Scripting.TextStream

    set oFS = new Scripting.FileSystemObject
    'let's read a file here
    set oStream = oFS.OpenTextFile("MYFILEPATHHERE")

    While Not oStream.AtEndOfStream
    MsgBox oStream.ReadLine()
    Loop
    'Now close the file
    oStream.Close
    'OK. We read a file. Now let's write one
    set oStream = oFS.CreateTextFile("C:\WINDOWS\DESKTOP\Test.txt")
    oStream.Write "This is a test"
    oStream.Close
    'Now release the objects
    set oStream = nothing
    set oFS = nothing





  5. #5
    Join Date
    Feb 2000
    Posts
    4

    Re: Save My file

    Thanks 4 your answer pal.
    I tried it and it worked for only one textbox.
    But how can I save for more than one box?
    (I have to write +-30 boxes)

    Chri


  6. #6
    Join Date
    Feb 2000
    Posts
    4

    Re: Save My file

    Thanx 4 your answer,...
    Can you explain me how I can open a file and import text to +-30 different textboxes? (with diferent text)

    Chri

    Please reply at my E-MAIL ([email protected])


  7. #7
    Join Date
    Feb 2000
    Location
    Indiana
    Posts
    308

    Re: Save My file

    Don't hard code the file number. The correct way to get your file number (the as #) is to call FreeFile(). This will give you the next available file number.
    You would need to repeat the code for each box. If you use an array of Text Boxes, you ca just loop through the array.
    e.g.

    'open your file here
    Dim iFileNum as Integer
    iFileNum = FreeFile()
    Open "<<FilePathHere>>" for Output as iFileNum
    for i = 0 to 29
    write #iFileNum, txt(i).Text
    next i
    'Close Your File and clean up





  8. #8
    Join Date
    Feb 2000
    Posts
    4

    Re: Save My file

    thanks pal,
    I'l have to rename all textboxses, but it's worth it...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured