highLIGHTED (06-10-2010)
How to open .txt files and how to save .txt files using textbox.
1. Open Visual Basic 2008 > Windows Forms Application.
2. Add 2 Buttons and 1 textbox (and opf and sfd)
3. It should now look something like this.
[IMG]https://i965.photobucke*****m/albums/ae133/MUSHIMOUSE/text.png[/IMG]
4. Double click on button1 and add this code.
[PHP]SaveFileDialog1.Filter = "text files (*.txt)| *.txt"
SaveFileDialog1.ShowDialog()
If SaveFileDialog1.FileName <> Nothing Then
My.Computer.FileSystem.WriteAllText(SaveFileDialog 1.FileName, TextBox1.Text, False)
End If[/PHP]
5. Double click button2 and add this code.
[PHP]OpenFileDialog1.Filter = "text files (*.txt)| *.txt"
OpenFileDialog1.ShowDialog()
Dim fname As String = OpenFileDialog1.FileName
If System.IO.File.Exists(fname) Then
Dim read As New System.IO.StreamReader(fname)
TextBox1.Text = read.ReadToEnd
read.Close()
End If[/PHP]
6. Ok now debug to see if it works.
7. If it works then pat yourself on the back and serve yourself some ice tea because you just made a simple Open & Save .txt program:]
highLIGHTED (06-10-2010)
Me.Text = System.IO.Path.GetFileNameWithoutExtension(Openfil edialog1.FileName)
Last edited by Hassan; 06-09-2010 at 05:01 AM.
why is it always you posting this small stuff? =\
Light travels faster than sound. That's why most people seem bright until you hear them speak.
This is not really a tutorial, you should have posted this in the snippet vault IMO.
Simple
But good job.
-Rest in peace leechers-
Your PM box is 100% full.
Posted in snippet vault.
NextGen1 (06-09-2010)