Why do I have to create a structure?
You do not need to create a structure. I said this is how I would manage moving data between different forms. It is also how a professional programmer would handle it.
It seem you need to learn to program Vb.net, C#, delphi or vb6...I do not understand why you say this
I am Microsoft certified in C# and .NET, and I am working on the C++ certification now. I also have been programming for 32 years, 17 of those years have been professionally. I've written software for thousands of clients all over the world ... so I know quite a bit about programming.
The reason I suggested a structure and a property is because of coding standards. It is generally not acceptable to change a class element directly, for example, to change the properties of a form textbox from another form or class. The changes should be handled by a method within the class to minimize errors from inadvertently changing something that should not have been changed. The best way to handle this in VB is through a public property or public method. (Public methods in a form should also be used in a limited way) That is why I suggested using a property.
This leads to the part about using a structure. Since there is more than one item being changed in the foreign class, and those items are all related, it becomes a natural solution to pass a single data structure than to pass several bits of data.
The structure handles the organization of the part and it is intuitive. This makes passing part information to other parts of the program much easier and you only need to pass one structure containing all the part information.
It certainly is more code, but it almost certainly will mean the code will be programmer friendly and portable, because when you see 'Part', you know exactly what it is and what it is being used for.
As far as the problem with scope for frm2, it depends upon other factors as to whether the data being passed will remain in scope after form1 is destroyed or the current function exits. If the data is being passed ByRef, then once the calling function is out of scope, the data sent is also out of scope, therefore the data ceases to exist. If the data is being passed ByVal, then all of the data is copied into a new memory location and remains in scope, regardless of the state of the original data.
I'd be more concerned with calling a modeless form from a form that can be destroyed before the modeless form is destroyed. It can create some real nasties. All I can say, is it is a good thing .NET is managed code.
Now that I look at the provided code a bit closer, I also see that the original poster is apparently creating a new form every time someone clicks in a DataGridView cell, but the new form is never shown. This would mean that frm2 goes out of scope when the event handler completes. I also noticed that the form containing the DataGridView is being destroyed when the click event handler completes. At this point frm2 is destroyed with form1.
Depending upon the desired effect, I might suggest, instead of Me.Close, using Me.Hide and then open frm2 as a modal form with Form1 as its parent. Then when form2 is closed, use its parent property to show the previous form... Me.Parent.Show() .. this ensures you return to the same location that you left. Now that you do that, instead of
Dim frm2 As New Form1
This will resolve the scope issue for frm2
Static frm2 As New Form1
I offered the solution as a gift. The original poster can accept it or they can reject it. I have no problem with it either way.