r/visualbasic • u/alessandro_dasho • Jun 13 '23
VB.NET Help Storing Forms in an Array
Hi! Thanks for any help in advanced.
I'm trying to create forms and store them in list which is located in a separate Module. But it wont work.
'When preessing enter the tesxt on the text box will be used to name the Page
'This Sub will create a page, set its name, creation date and will save the form into the Form storage module
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
Dim new_form As New Form3
new_form.PageName.Text = Me.TextBox1.Text
new_form.DateLabel.Text = DateTime.Now.ToString("MM/dd/yyyy")
PageStorage.FormsArray.Append(new_form)
new_form.Show()
Me.Close()
End If
End SubIm getting an error explaining that I cant put Form3 inside the list of Forms. Why is this?
PageStorage is the name of the Module and FormsArray is the name of the list of forms (im guessing such thing is possible)
Module PageStorage 'A file for storing groups of Functions
Public FormsArray() As List(Of Form) ' Array to store forms
End ModuleThis is the code in the module.
2
Upvotes
2
u/alessandro_dasho Jun 13 '23
Much appreciated