Can someone help me save some text to a text file in VB 2005? (VB 6's way dosn't work)
Printable View
Can someone help me save some text to a text file in VB 2005? (VB 6's way dosn't work)
in VB6 you can use the richtextbox for saving a txt file
in vb 2005 you can use the richtextbox too:
has you can see i use more objects to these example:Code:SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName,RichTextBoxStreamType.PlainText)
button and savefiledialog(don't forget to write the extencion *.txt)
i hope these helps
PS: in vb6 is more or less the same....
Moved to VB.NET
Thank you for your help, but is there a way to do it without the FD?Quote:
Originally Posted by joaquim
vb.net Code:
IO.File.WriteAllText("file path here", myString)
vb Code:
IO.File.WriteAllText("file path here", myString)
When using this code how would I make the file name varie?
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