I want to be able to take some user inputs and then using the 'filesave' write a vb code file which I could load and get the program to execute. At the minute changing 4 text boxes on the main form to 4 values entered on the values form (where the save button is). I've tried this code;
Code:
Dim filesave As StreamWriter
Dim num1, num2, num3, num4 As String
num1 = TextBox1.Text
num2 = TextBox2.Text
num3 = TextBox3.Text
num4 = TextBox4.Text
filesave = My.Computer.FileSystem.OpenTextFileWriter("save.vb", False)
filesave.WriteLine("Private Sub Load_Execute(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loadfile.click")
filesave.WriteLine("Dim num1, num2, num3, num4 As String")
filesave.WriteLine("num1 =" num1)
filesave.WriteLine("num2 =" num2)
filesave.WriteLine("num3 =" num3)
filesave.WriteLine("num4 =" num4)
filesave.WriteLine("Main.Label1.Text = num1")
filesave.WriteLine("Main.Label2.Text = num2")
filesave.WriteLine("Main.Label3.Text = num3")
filesave.WriteLine("Main.Label4.Text = num4")
filesave.WriteLine("Me.Close()")
filesave.WriteLine("End Sub")
It keeps saying 'Comma, ')', or a valid expression continuation expected' after the lines with ("num1 =" num1). Is there another way of writing this as or is there something else I need to add. I'm trying to add a line that would declare num1 in this new code document as num1 was when the file was written. I've attached an example of what the written file should look like if num1 was one, num2 two et cetra. I'm not exactly sure if this would even work or if there is an easier way to approach it. Any help would be greatly appreciated.