simple examples are one thing... mis-information is another... the problem is that all too often around here, we see people with a little bit of information becoming dangerous because they don't completely understand the inner workings.
Let's take your Form2 example... this is a classic example of when good intentions go bad... and I put most of the blame on VB for this because it has something that no other language has: default form instances... and not understanding how they work can lead to some dire consequences.
Try this out... start a new project... give it two forms, Form1 and Form2. In the properties of Form2, set the Text property to "This is Form2" ... now add a button to Form1, and add this code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Text = "New Caption"
Dim myForm As New Form2
Form2.Show()
myForm.Show()
End Sub
Now you can see the first line modifies Form2... by changing the caption... and then I create a new instance of Form2 ... but what happens when the forms are shown? Their captions are different. That's because I didn't change Form2 at all ... what I changed was VB's Default Instance of that form. Behind the scenes, an instance of Form2 was created, and it was then returned back as the Default instance of that form. I didn't create it, VB takes care of that. The same thing is happening with the typed dataset... it's just ticked away in the designer code.
now change the code above to this:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Text = "New Caption"
Dim myForm As New Form2
myForm = Form2
Form2.Show()
myForm.Show()
End Sub
What happened this time? Only one form showed up... and it had the "New Caption" ... that's because I set myForm equal to the default instance.. so now they are one in the same... two variables pointing to the same instance.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Text = "New Caption"
Dim myForm As New Form2
myForm = Form2
Form2.Text = "And another cpation"
Form2.Show()
myForm.Show()
End Sub
Same thing again... one form... with the "And another caption" title.
yeah, sure programming 101 doesn't break it down to the atomic level... but perhaps they should. And yes, analogies and comparisons are good, I use eggs, cars, and boxes a lot. But you have to make sure that the analogies are correct. I tried to be as simple as I could in my initial reply to the OP... the difference is that one says "I need a box" and the other says "I need a box, go make it for me" .... pure and simple. OK, so maybe I'm in the wrong for trying to set the record straight in your post. If it'll make you happy, I'll simply ignore any further posts from you. But I'll leave you with this, it scares me to death sometimes some of the misinformation I see out there... someday, one of these guys is going to be programming my pacemaker... I want to make dog dang sure that who ever does that, gets it right. there will be no staging environment. There will be no testing environment. So any chance I get to set some one straight, you're dang right I'll take advantage of the situation.
If everyone started programming like their life depended on it, we would probably see a huge increase in bug free software.