|
-
Mar 15th, 2008, 03:12 PM
#1
Thread Starter
Member
Saving a *.txt file in VB 2005 - Help Please
Can someone help me save some text to a text file in VB 2005? (VB 6's way dosn't work)
-
Mar 15th, 2008, 05:04 PM
#2
PowerPoster
Re: Saving a *.txt file in VB 2005 - Help Please
in VB6 you can use the richtextbox for saving a txt file
in vb 2005 you can use the richtextbox too:
Code:
SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName,RichTextBoxStreamType.PlainText)
has you can see i use more objects to these example:
button and savefiledialog(don't forget to write the extencion *.txt)
i hope these helps
PS: in vb6 is more or less the same....
Last edited by joaquim; Mar 15th, 2008 at 05:12 PM.
-
Mar 15th, 2008, 08:14 PM
#3
Re: Saving a *.txt file in VB 2005 - Help Please
-
Mar 15th, 2008, 08:31 PM
#4
Thread Starter
Member
Re: Saving a *.txt file in VB 2005 - Help Please
 Originally Posted by joaquim
in VB6 you can use the richtextbox for saving a txt file
in vb 2005 you can use the richtextbox too:
Code:
SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName,RichTextBoxStreamType.PlainText)
has you can see i use more objects to these example:
button and savefiledialog(don't forget to write the extencion *.txt)
i hope these helps
PS: in vb6 is more or less the same....
Thank you for your help, but is there a way to do it without the FD?
-
Mar 15th, 2008, 08:56 PM
#5
Re: Saving a *.txt file in VB 2005 - Help Please
vb.net Code:
IO.File.WriteAllText("file path here", myString)
-
Mar 15th, 2008, 09:19 PM
#6
Thread Starter
Member
Re: Saving a *.txt file in VB 2005 - Help Please
vb Code:
IO.File.WriteAllText("file path here", myString)
When using this code how would I make the file name varie?
-
Mar 15th, 2008, 09:24 PM
#7
Re: Saving a *.txt file in VB 2005 - Help Please
The first parameter is just a String. That String can come from anywhere. One place it might come from is the FileName property of an OpenFileDialog, thus allowing the user to select the destination, e.g.
vb.net Code:
Using ofd As New OpenFileDialog If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then IO.File.WriteAllText(ofd.FileName, Me.TextBox1.Text) End If End Using
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|