|
-
Apr 19th, 2009, 11:18 PM
#1
Thread Starter
Lively Member
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?
-
Apr 20th, 2009, 01:20 AM
#2
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.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Apr 20th, 2009, 04:11 AM
#3
Re: using a button to save info input in textboxes
Move to VB.Net Forum.
pino
-
Apr 20th, 2009, 06:42 AM
#4
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)
-
Apr 20th, 2009, 11:49 PM
#5
Thread Starter
Lively Member
Re: using a button to save info input in textboxes
 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?
Last edited by DiLDoR; Apr 20th, 2009 at 11:53 PM.
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
|