I am trying to figure out if it is possible to dynamically create a new empty label on Form2 when the user clicks 'Yes' button in the message box and then write new information from the text box to the new label creating a list made up of labels with data in them. I know that this is possible if you are doing everything on one form but not sure about passing between forms. I have been expirimenting with this using a function (AddNewLabel) and I think that I am on the right track but am not certain. Here is the code (a large portion courtesy of PsychoCoder. Thanks PsychoCoder!) Any ideas are welcome. I am continuing to play with this so if I find a solution before someone suggests one I will post it. Thanks!
Public Class Form1 Private Items As String = String.Empty Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click 'Create a DialogResult Variable Dim StrNote As DialogResult Dim str As String 'Get the value from the MessageBox StrNote = MessageBox.Show("Add another item?", "MyApplication", _ MessageBoxButtons.YesNo, MessageBoxIcon.Question) 'Check to see if user selected Yes or No If StrNote = DialogResult.Yes Then 'Add items AddNewLabel() str = SetValue(Items) 'Empty the The TextBox txtfrm1.Text = String.Empty 'Set focus to the TextBox txtfrm1.Focus() Else str = SetValue(Items) 'Set the text property of the label to the items variable Form2.Label1.Text = str Form2.Show() End If End Sub Public Function SetValue(ByVal value As String) As String If String.IsNullOrEmpty(value) Then 'No Value present so add a value Items = txtfrm1.Text + Environment.NewLine End If Return Items End Function Public Function AddNewLabel() _ As System.Windows.Forms.Label ' Create a new instance of the Label class. Dim aLabel As New System.Windows.Forms.Label Form2.Controls.Add(aLabel) aLabel.Size = New Size(39, 13) aLabel.Location = New Point(51, 34) aLabel.Text = txtfrm1.Text Return aLabel End Function End Class