Visual Basic .NET Nightmare or Guide to upgrading a Guru.

Page 3

What's the point of Objects?


  1. Let's do that by closing your current solution so that all you have is the IDE open. or if your just getting to it, open the IDE without a solution.

  2. Now let's open the object browser. This is one of the most handy tools in VB. If your good at figuring stuff out it's also a learning tool although it is meant as a reference.

  3. So what do we have for objects? Nothing as of yet, the point is you can't have objects without a project and vice versa. Now create a new solution and then add a project, let's call our Windows Application "Demo". This creates our default form object. Our form's object is also based on it's class. You can see the relationship between your class's code and the object you created from it. So your Form's object is based on the class code created by the .NET framework developers.

  4. Now we have all kinds of Objects or Base classes for our project.  And a lot of them are system.  So what does this mean?

Setting the cosmic Key.

What's in a Name Space?  This is kind of new to me as well. I have always taken the dot extension for granted in VB the idea that I could just type Me and the Dot and get all kinds of aspects automatically was amazing enough. But what it really is, is the structure of your code's referencing objects. AKA the Name space.  For System there are a few different ones listed already in your object browser. System itself is one of them. Let's focus on System.Windows.Forms.

Private MyForm As New System.Windows.Forms.Form()
Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click




Let's try something similar with both VB6 and VB7 combined.  The new way of getting your form on the screen.

Private MyForm As New form2
Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

e.Cancel = True


<End Sub

If I created form2 who created form1? As you can probably see when your project runs it creates the start-up object. Otherwise the program would have no where to start. You can also change your startup to a module named main and and it will call the sub main procedure just like in VB6.


Page 4