Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > File I/O and Registry > Saving a file..


Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2004, 11:42 PM
ben_Sewell_007 ben_Sewell_007 is offline
Freshman
 
Join Date: Feb 2004
Posts: 28
Post Saving a file..


ok the first thing. I am building a html code generator which is a freelance project for fun and it is my first sensible project (3 rubbish basic programs made). I get the users input and the user clicks on "Output now", which is a button. It generates the code, which is place in txtOutput. I want the ability to save the Output as a file.. prefebly if the user clicks on a button "save file" and then has to input a filename.. eg they type in "index" or "main". All files saved should be saved in the syntax "*.htm". Can anybody point a way to do this?

Ben
Reply With Quote
  #2  
Old 02-22-2004, 11:46 PM
dan_'s Avatar
dan_ dan_ is offline
Centurion
 
Join Date: Sep 2003
Location: Aussie Computer
Posts: 151
Default

Use the CommonDialog controls. ShowSave Properties.
Dan_
__________________
Digg.com member
Reply With Quote
  #3  
Old 02-23-2004, 12:37 AM
malloc malloc is offline
Senior Contributor
 
Join Date: Feb 2004
Location: The land of Oz
Posts: 851
Default

When you create an outputfile you can give it the extesion you want.

Code:
Open "output.htm" for output as #1

You could use a commondialog to let the user give the name of the file to create.
You can set the Filter property to something like:

Code:
CommonDialog1.Filter = "HTML files (*.htm)|*.htm"
Reply With Quote
  #4  
Old 02-23-2004, 12:41 AM
Ej12N Ej12N is offline
Centurion
 
Join Date: Feb 2004
Posts: 149
Default

Love it! full commented so you get how to use it and learn
Code:
Private Sub cmd_Click() Dim Filename As String 'declare variable On Error GoTo strCancel 'If the user press cancel goto strCancel With CD ' CD = Commondialog name .CancelError = True ' make an error if user press cancel .Filter = "HTM Files *.htm|*.htm" 'Filter type of file .ShowSave 'show the save dialog Filename = .Filename 'this is the filename that the user gonna type Open Filename For Output As #1 Print #1, txt.Text 'put what's on txt.Text to the user file *** in you case this would be txtOutput Close #1 'save it =) End With strCancel: 'if cancel pressed then exit sub, so no file is created =) End Sub
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
File I/O GavinO Tutors' Corner 5 04-17-2013 01:18 PM
Installation Problem - PLs help urgenlty dpdsouza Installation / Documentation 4 12-02-2004 07:09 PM
Doesn't want to register! MikeyM Installation / Documentation 5 03-02-2003 08:22 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->