M
Marc
The first part of the below writes the name and location of all
buttons on a from to a text file. The second part reads that
information back in and recreates the buttons. My problem is reading
the location value back in where I marked ?????????????????????. As it
wont accept a string value?
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Save.Click
TW = System.IO.File.CreateText("C:\MyTextFile.txt")
Dim C As Control
For Each C In Me.Controls
If TypeOf C Is Button Then
TW.WriteLine(C.Text)
TW.WriteLine(C.Location)
End If
Next
TW.Close()
End Sub
Private Sub Load_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Load.Click
Dim TextFileStream As System.IO.TextReader
TextFileStream = System.IO.File.OpenText("C:\MyTextFile.txt")
Dim MyFileContents As String
Do
MyFileContents = TextFileStream.ReadLine
Dim test As New Button()
Me.Controls.Add(test)
test.Text = MyFileContents
test.Location = ????????????????????????????????
AddHandler test.MouseDown, AddressOf Me.Thebutton_MouseDown
AddHandler test.MouseMove, AddressOf Me.Thebutton_MouseMove
AddHandler test.MouseUp, AddressOf Me.Thebutton_MouseUp
Me.Controls.Add(test)
MsgBox(MyFileContents)
Loop Until MyFileContents = ""
TextFileStream.Close()
End Sub
buttons on a from to a text file. The second part reads that
information back in and recreates the buttons. My problem is reading
the location value back in where I marked ?????????????????????. As it
wont accept a string value?
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Save.Click
TW = System.IO.File.CreateText("C:\MyTextFile.txt")
Dim C As Control
For Each C In Me.Controls
If TypeOf C Is Button Then
TW.WriteLine(C.Text)
TW.WriteLine(C.Location)
End If
Next
TW.Close()
End Sub
Private Sub Load_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Load.Click
Dim TextFileStream As System.IO.TextReader
TextFileStream = System.IO.File.OpenText("C:\MyTextFile.txt")
Dim MyFileContents As String
Do
MyFileContents = TextFileStream.ReadLine
Dim test As New Button()
Me.Controls.Add(test)
test.Text = MyFileContents
test.Location = ????????????????????????????????
AddHandler test.MouseDown, AddressOf Me.Thebutton_MouseDown
AddHandler test.MouseMove, AddressOf Me.Thebutton_MouseMove
AddHandler test.MouseUp, AddressOf Me.Thebutton_MouseUp
Me.Controls.Add(test)
MsgBox(MyFileContents)
Loop Until MyFileContents = ""
TextFileStream.Close()
End Sub