How do I get an element and its property from a separate form and extract it on another form? [duplicate]
Clash Royale CLAN TAG#URR8PPP
How do I get an element and its property from a separate form and extract it on another form? [duplicate]
This question already has an answer here:
Form 2 (txtMsgName is the element I am trying to access in Form 1)
Public Class Form2
Private Sub btnMsgName_Click(sender As Object, e As EventArgs) Handles btnMsgName.Click
DialogResult = DialogResult.Yes
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
DialogResult = DialogResult.No
End Sub
End Class
Form 1 (References text box in Form 2, then displays contents of it on a MessageBox)
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myForm As New Form2
If myForm.ShowDialog = DialogResult.Yes Then
txtName.Text = Form2.txtMsgName.Text
MessageBox.Show(txtName.Text, "Hello")
End If
End Sub
End Class
Every time I run the code, it works, it has no errors, but the message box does not display any of the contents
I am using Visual Studio Community 2017
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.