Results 1 to 3 of 3

Thread: Save and Save as

  1. #1
    Guest

    Talking

    Can anyone please tell me why we need to have save and save as BOTH in our program... and how can we handle it? i mean, do we need to have 2 set of Write #filenum? and what would be the best way to have both save and save as in program with least codes

  2. #2
    Guest
    Goes something like:

    Code:
    Private Sub Save_Click()
    If Dir(App.Path & "\preview.htm") <> "" Then
    Open App.Path & "\preview.htm" For Output As #1
    Print #1, Text1.text
    Close #1
    Else
    Call SaveAs_Click
    End If
    End Sub
    
    Private Sub SaveAs_Click()
        Dim iFile As Integer
        On Error GoTo User_Cancelled
        With CommonDialog1
        .CancelError = True
        .DialogTitle = "Select a html File.."
        .Filter = "Text (*.htm)|*.htm"
        .ShowSave
        iFile = FreeFile
        If .filename = "" Then Exit Sub
        Open .filename For Output As iFile
        Print #iFile, Text1.text
        Close iFile
        End With
    User_Cancelled:
    End Sub

  3. #3
    Guest
    You need both Save and Save As because many people are tired of too many work. After all, not many people want to browse through folders too many times. You'll need Save As for some want to save twice.

    The easiest way?

    Code:
    Public NowFilename as String = ""
    Public Sub Save(Filename As String)
      Open Filename For Output As #1
      Print #1, "Blahblah"
      'Whatever...
      Close #1
    End Sub
    Private Sub mnuSave_Click()
      If NowFileName = "" Then
        'code...
      End If
      If Dir NowFileName <> "" then Save NowFileName
    End Sub
    Private Sub mnuSaveAs_Click()
      'Code to get NowFileName
      If Dir NowFileName <> "" then Save NowFileName
    End Sub
    '...
    '...

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