using a button to save info input in textboxes
this application I'm writing is for Employee Data. I have 7 texboxes and 1 combo box.
With the file menu I have used that function to save info inputed in one texbox. However for this application I need to use btnSave button to save the record.
here is what I used for the file>save menu:
Code:
Dim result As DialogResult
'find input file
With OpenFileDialog1
.Title = "Find Input File"
.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
.CheckFileExists = True
result = .ShowDialog()
End With
'canceled out?
If result = DialogResult.Cancel Then
Exit Sub
End If
'remember name of input file
strInputFileName = OpenFileDialog1.FileName
'open files for input
Dim inputfile As System.IO.StreamReader
inputfile = System.IO.File.OpenText(strInputFileName)
'clear and fill textbox with content of input file
TextBox1.Clear()
Do Until inputfile.Peek() = -1
Dim strTextLine As String
strTextLine = inputfile.ReadLine()
TextBox1.Text = strTextLine & ControlChars.NewLine
Loop
'close the channel
inputfile.Close()
How can I implement this with a button?
Re: using a button to save info input in textboxes
If I'm not mistaken that code is VB.NET!
Furthermore the code posted isn't doing any save into a file, it rather reads from a file and puts the contents into TextBox1!
And on your question, "How to use code from a Menu on aCommandButton, the answer is: The use is the same, you could copy/paste the code from one Sub to the other.
Re: using a button to save info input in textboxes
Move to VB.Net Forum.
pino
Re: using a button to save info input in textboxes
I think this is what you are looking for.
Code:
System.IO.File.WriteAllText("c:\hack.txt", TextBox1.Text)
Re: using a button to save info input in textboxes
Quote:
Originally Posted by
opus
If I'm not mistaken that code is VB.NET!
Furthermore the code posted isn't doing any save into a file, it rather reads from a file and puts the contents into TextBox1!
And on your question, "How to use code from a Menu on aCommandButton, the answer is: The use is the same, you could copy/paste the code from one Sub to the other.
oh Ok I was not sure if visual basic in visual studio is .net at all. thanks. lul what about the option of deciding where to save it?