Solved

Saving contents of a TextBox

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 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

19 Experts available now in Live!

Get 1:1 Help Now