我实际上得到了这个:
Imports System.IO
Public Class Form1
Dim a As StreamReader
Dim b As String
Dim c As String = "C:\Users\me\Desktop\WindowsApplication2\test.txt"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not File.Exists(c) Then
Dim d As FileStream
d = File.Create(c)
d.Close()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim button As New Button
button.Location = New Drawing.Point(50, 50)
button.Size = New System.Drawing.Size(170, 50)
button.Text = TextBox1.Text
Me.Controls.Add(button)
If TextBox1.Text = Nothing Then
MsgBox("Enter a name.")
Else
File.AppendAllText(c, TextBox1.Text & vbCrLf)
TextBox1.Text = ""
MsgBox("Button created !", MsgBoxStyle.Information, "Saved")
End If
End Sub
我想要比单击button1时创建一个按钮时,新按钮会被存储在.txt文件中,当我重新启动程序时,会重新加载新按钮。
由于