How to open and save files in VB 6
-
- Posts: 137
- Joined: Sun Jan 30, 2005 7:32 am
- Location: Mississauga
How to open and save files in VB 6
Exactly what the title says. I want the code though so that when you click save it will let you browse directorys and then save under any file name and same with open except txt files only please.
Signature exceeded 500x120 pixels.
For VB 6, I am not sure...but for VB .NET I know.
This may or may not work for VB 6.
This may or may not work for VB 6.
Code: Select all
Dim dlg As SaveFileDialog = New SaveFileDialog
dlg.Filter = "Text Files (*.txt) |*.txt"
dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal) ' This sets the intial path to 'My Documents'
If DialogResult.OK = dlg.ShowDialog Then
Dim sr As System.IO.StreamWriter = New System.IO.StreamWriter(dlg.FileName)
sr.Write(RichTextBox1.Text)
sr.Flush() ' Probably not needed, but will make sure that everything that's been streamed is written
sr.Close()
End If
-
- Posts: 5426
- Joined: Sat Jul 24, 2004 12:12 pm
- Location: I'm a Paranoid
- Contact:
![]() |
![]() |