Hi, I'm totally new to the programming area. I'm using VB 2008 and i'm trying to save three textboxes in a text format. I have tried some code but my problem is that i don't want to save always at the same name (test.txt). How can I do it.
Here is the code that i'm using (and probably has lot of mistakes :'( )
Public Class Form1
Const mForm1Name As String = "c:\test.txt"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Form1 As System.IO.StreamWriter
Form1 = My.Computer.FileSystem. _
OpenTextFileWriter(mForm1Name, True)
With SaveFileDialog1
.InitialDirectory = "c:\"
.Filter = "Text files | *.txt"
.ShowDialog()
End With
Form1.WriteLine(TextBox1.Text)
Form1.WriteLine(TextBox2.Text)
Form1.WriteLine(TextBox3.Text)
Form1.Close()
End Sub
End Class
-----------------
i understand that the problem is on the top where i've placed Const mForm1Name As String = "c:\test.txt", but when i'm taking it out gives back a mistake. What can i do?
Also my form doesn't close when i save
Here is the code that i'm using (and probably has lot of mistakes :'( )
Public Class Form1
Const mForm1Name As String = "c:\test.txt"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Form1 As System.IO.StreamWriter
Form1 = My.Computer.FileSystem. _
OpenTextFileWriter(mForm1Name, True)
With SaveFileDialog1
.InitialDirectory = "c:\"
.Filter = "Text files | *.txt"
.ShowDialog()
End With
Form1.WriteLine(TextBox1.Text)
Form1.WriteLine(TextBox2.Text)
Form1.WriteLine(TextBox3.Text)
Form1.Close()
End Sub
End Class
-----------------
i understand that the problem is on the top where i've placed Const mForm1Name As String = "c:\test.txt", but when i'm taking it out gives back a mistake. What can i do?
Also my form doesn't close when i save