Results 1 to 3 of 3

Thread: Binary Files - easy question !(resolved)

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Location
    Uk
    Posts
    10

    Binary Files - easy question !(resolved)

    Hi again,

    I am currently learning how to use binary files.

    I have been given an example which is a basic text editor which works fine.

    What i don't understand is "How does the program know where to store the saved file on my pc and where will that be ?"

    Code is below

    Private Sub mnuFileNew_Click()
    txtDoc = ""
    End Sub

    Private Sub mnuFileOpen_Click()
    Dim sText As String, sFileName As String
    Dim iFileNum As Integer

    'Get the filename to open
    sFileName = InputBox("File name", "Open")
    iFileNum = FreeFile 'Get the next free file number

    Open sFileName For Binary As iFileNum
    sText = Space(LOF(iFileNum)) 'Create a dummy string to hold the text
    Get iFileNum, , sText 'Load the text from the file
    txtDoc = sText
    Close iFileNum

    End Sub

    Private Sub mnuFileSaveAs_Click()
    Dim sText As String, sFileName As String
    Dim iFileNum As Integer

    sFileName = InputBox("File name", "Save")
    iFileNum = FreeFile

    Open sFileName For Binary As iFileNum
    sText = txtDoc
    Put iFileNum, , sText 'Save the text to the file
    Close iFileNum

    End Sub
    Last edited by NewbAl; Oct 15th, 2002 at 10:15 AM.

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