Solved

Saving contents of a TextBox

Posted on 2004-10-14
3
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

761 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