rwan rwan - 10 months ago 54 Question

VB 13 windows form - how do I pass my variable between two forms [New to coding]

On one form I have:

lblQuizName.Text = "Enter Quiz Name"

Later on I call a separate form:


How do I move the text from
into this form as it doesn't let me write a parameter when I call

Especially because it has
Public Class frmQuizForStudents
at the top, I cannot write: "
Public Class frmQuizForStudents(lblQuizName)

Answer Source

You can create a new constructor using the parameter needed for your frmQuizForStudents form :

Public Class frmQuizForStudents

    sub new(QuizName as string)
         '... Code here
    end sub

end class

Also, to call this Form you will need to create a new instance of it before using the new parameter:

dim NewQuizForStudents as New frmQuizForStudents(lblQuizName.Text)