Solved

Saving contents of a TextBox

Posted on 2004-10-14
3
208 Views
Last Modified: 2010-04-23
Hello everyone,

I have a small problem that maybe somone could help me with. I have an app that lets me input raw sql commands and load sql scripts but what I would like to do and cannot accomplish is get the savefiledialog to save the contents of the textbox to a .sql file so I can use it later. I am able to get the box to open and I can get it to write the file but am not able to give a filename or get it to write the contents of the box

Thanks for the help.
Joe
0
Comment
Question by:JoeDW
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
mdougan earned 350 total points
ID: 12308811
Hi JoeDW,


            Dim fWriter As StreamWriter
            Dim sLine As String
            Dim sFileName As String
            Dim dresult As System.Windows.Forms.DialogResult

            dlgSave.CheckFileExists = False
            dlgSave.AddExtension = True
            dlgSave.Filter = "Excel Spreadsheet|*.xls|Comma Separated Values|*.csv|Tab Separated Values|*.tsv|Fixed Layout|*.txt|All Files|*.*"
            dresult = dlgSave.ShowDialog()

            Me.Refresh()

            If (dlgSave.FileName <> "") And (dresult = DialogResult.OK) Then

                sFileName = dlgSave.FileName

                fWriter = File.CreateText(sFileName)
                sLine = txtSQL.Text
                fWriter.WriteLine(sLine)
                fWriter.Flush()
                fWriter.Close()
            End IF


Cheers!
0
 
LVL 1

Author Comment

by:JoeDW
ID: 12308867
sweet, that worked flawlessly!! Just had to change the txtSQL to the name of the textbox and it worked perfect. Thanks a million. Here is an added 100 points for the quick reply.

Awesome!
0
 
LVL 18

Expert Comment

by:mdougan
ID: 12308971
Thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question