How to save as to a new file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bullitt
    New Member
    • Dec 2007
    • 21

    How to save as to a new file.

    I have a program in visual basic 6 and there are some numbers that I want to save to a file. I have the common dialog now and I can type in a filename and extension, but this is not making the new file.

    So my question is, how can I make a file?

    Thanks already
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try to use FileSystemObjec t .

    Comment

    • lotus18
      Contributor
      • Nov 2007
      • 865

      #3
      Originally posted by Bullitt
      I have a program in visual basic 6 and there are some numbers that I want to save to a file. I have the common dialog now and I can type in a filename and extension, but this is not making the new file.

      So my question is, how can I make a file?

      Thanks already
      You don't necessarily have to type the file extension. What you need is to filer the file extensions.

      CommonmDialog.F ilter = "Microsoft Access Database (*.mdb)|*.mdb|A ll Files " & _
      "(*.*)|*.*"

      Comment

      • Ali Rizwan
        Banned
        Contributor
        • Aug 2007
        • 931

        #4
        You can use FSO for such purpose.

        To create a file you can use following code


        Code:
        dim fso as new filesystemobject
        dim f as file
        dim t as textstream
        
        
        private sub cmdsave_click()
        
        fso.createtextfile(Your Path)
        
        set f=fso.getfile(File Path you creates)
        set t=f.openastextstream(Select Writing mode)
        
        t.write(text1.text)
        
        t.close
        
        end sub
        For further help you can contact me.

        Regards
        >> ALI <<

        Comment

        • jimmylee
          New Member
          • Feb 2008
          • 17

          #5
          Originally posted by Bullitt
          I have a program in visual basic 6 and there are some numbers that I want to save to a file. I have the common dialog now and I can type in a filename and extension, but this is not making the new file.

          So my question is, how can I make a file?

          Thanks already
          Dim objFSO As FileSystemObjec t
          Private Sub Command1_Click( )
          Set objFSO = New FileSystemObjec t
          objFSO.CreateTe xtFile "C:\testaa. txt"
          End Sub

          Comment

          Working...