RadhaKrishnaKiJaya
asked on
How to write the New() method when a form is called by two different forms
Hello Experts,
I have a form lets say "Form A". I have two different forms called "Form B" and "Form C". Now my program(Form B) is calling "form A" with some parameters. I have defined a New() method.
Now my requirement is that Form C should also call Form A with some parameters. What can I do so that the New() method will understand which form is calling.
Thanks in advance.
I have a form lets say "Form A". I have two different forms called "Form B" and "Form C". Now my program(Form B) is calling "form A" with some parameters. I have defined a New() method.
Now my requirement is that Form C should also call Form A with some parameters. What can I do so that the New() method will understand which form is calling.
Thanks in advance.
ASKER
Thank you for your reply.
Right now my New function looks like this.
Public Sub New(ByVal formParameter As StockSearch) ''Where stockSearch is the name of the form
InitializeComponent()
StockSearchObj = formParameter
End Sub
So can you please tell me how to change the code.
Right now my New function looks like this.
Public Sub New(ByVal formParameter As StockSearch) ''Where stockSearch is the name of the form
InitializeComponent()
StockSearchObj = formParameter
End Sub
So can you please tell me how to change the code.
Make sure that you have a class variable like so to hold the value.
Dim StockSearchObj As StockSearch
Otherwise it looks good. Are you having issues with it?
Dim StockSearchObj As StockSearch
Otherwise it looks good. Are you having issues with it?
ASKER
Thanks for ur reply. This works fine when the stocksearch.vb call the frmModify.vb. Now I want RackStatus.VB should call the same frmModify.vb.
>>So can you please tell me how to change the code.
You run whichever code is appropriate to the calling form. eg. with a switch/case statement or an if statement.
You run whichever code is appropriate to the calling form. eg. with a switch/case statement or an if statement.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much. It worked!!
Not a problem RadhaKrishnaKiJaya, glad I was able to help.
eg.
New(int i)
and
New(String s, int j)
OR
You could just pass something to identify which type the calling form is as a parameter
eg.
New(int TypeOfForm)
{
switch(TypeOfForm)
{
case 1:
....
case 2:
....