Solved

Saving contents of a TextBox

Posted on 2004-10-14
3
183 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now