I\'m making a program that generates SQL Server code to use it in my VB.NET program.
I have this first form that contains the connection like you see in picture belo
The simplest way to pass a value from one form to another is to implement the New
method on the form you want to pass the value to:
Form1
:
Public Class Form1
Private Sub btnPass_Click(sender As Object, e As EventArgs) Handles btnPass.Click
Dim form As New Form2(TextBox1.Text)
form.Show()
End Sub
End Class
Form2
:
Public Class Form2
Public Sub New(ByVal value As String)
' This call is required by the designer.
InitializeComponent()
Label1.Text = value
End Sub
End Class
Screenshot:
This question is a bit confusing, but this is how I would pass a variable from one form to another.
Create a class /w variable.
Public Class Variables
Public Shared Property imavariable As String
Get
Return m_imavariable
End Get
Set(value As String)
m_imavariable = value
End Set
End Property
Private Shared m_imavariable As String
End Class
Set the variable from form 1... variables.imavariable = string
Read the variable from form2.... string = variables.imavariable