-
Open a Form
I am trying to make the move from vb6 to vb.net. How do you call a form that you have in your project. This is the the I want to do. I have two forms, when someone clicks on a text box in one form I want to populate another form with some strings and display it. For the life of me I can't see how to do this.
Thanks.
-
If you want to make it mandatory that info gets passed in order to display the form then you can add the data as parameters to the New() method of the form and add your code to the bottom of it. Otherwise you can make override the New() method with the parameters so you can use either or. If you override the Constructor (New) then make sure and call the original one first either with:
New()
'or
MyBase.New()
-
You the man Ed, could you post a little example code?
-
Try this
coding in button:
Dim frm1 As form
frm1=new formA(b)
frm1.show
coding in form you want to call:
(Click the "Windows Form Designer generated code" first)
Dim test As string
Public sub new(ByVal a As String)
MyBase.New()
test=a
"b" is a value you want to send to the form you call.
"a" receive value "b".
-
SO this part:
coding in button:
Dim frm1 As form
frm1=new formA(b)
frm1.show
Goes into the form where I am trying to call the form?
And this part:
(Click the "Windows Form Designer generated code" first)
Dim test As string
Public sub new(ByVal a As String)
MyBase.New()
test=a
Goes into the form I am trying to call? If so where?
-
try again
Double-click the form u want to call, u can see coding.
You can find the coding (almost) like this :
Public Class formA
inherits System.Windows.Forms.Form
+ Windows Form Designer generated code
After click + at " + Windows Form Designer generated code "
you can see this coding:
Public sub new()
MyBase.New()
try to change to :
Dim test As string
Public sub new(ByVal a As String)
MyBase.New()
test=a