|
-
Apr 8th, 2012, 10:28 AM
#10
Thread Starter
Junior Member
Re: Saving and Loading TextBoxes and Labels
 Originally Posted by .paul.
try this:
vb Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'save
Dim sfd As New SaveFileDialog
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
IO.File.WriteAllLines(sfd.FileName, New String() {TextBox1.Text, TextBox2.Text, Label3.Text})
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'load
Dim ofd As New OpenFileDialog
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim lines() As String = IO.File.ReadAllLines(ofd.FileName)
If lines.Count = 3 Then
TextBox1.Text = lines(0)
TextBox2.Text = lines(1)
Label3.Text = lines(2)
End If
End If
End Sub
End Class
Any way to get that to look for a folder and only at .txt like with Dialogs -> OpenFileDialog and SaveFileDialog?
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
|