Hi,
I have a question regarding using a TextBox in second form within the same project.
Currently I am using two forms. From the main form you can click a button which opens the second form. There, I want to type in an integer value into a textbox and use it for the code in my first form.
Here's my code:
This doesn't work. Theres no value at all in the MsgBox.
Instead of the first example I could also use this one, which gives me a zero in the MsgBox:
Where is my mistake? What can I do betterß
Please help.
I have a question regarding using a TextBox in second form within the same project.
Currently I am using two forms. From the main form you can click a button which opens the second form. There, I want to type in an integer value into a textbox and use it for the code in my first form.
Here's my code:
Public Class Form1
Private Sub configure_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles configure_button.Click
Dim F As New Form2
F.Show()
End Sub
Private Sub Test_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test_button.Click
Dim test
test = Form2.TextBox1.Text
MsgBox(test)
End Sub
End Class
This doesn't work. Theres no value at all in the MsgBox.
Instead of the first example I could also use this one, which gives me a zero in the MsgBox:
Public Class Form1
Private Sub Test_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Test_button.Click
MsgBox(Form2.testvar)
End Sub
End Class
Public Class Form2
Public testvar As New Integer
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
testvar = TextBox1.Text
End Sub
End Class
Where is my mistake? What can I do betterß
Please help.
Last edited: