Results 1 to 5 of 5

Thread: Form Fundamentals

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Form Fundamentals

    Hi,

    After browsing this site for three months, I have realised that my attempt to learn VB.NET has sufferred from many gaps, so I have started to go through a re-learning schedule. That took me to

    http://samples.gotdotnet.com/quickstart/winforms/

    Their very first coding is

    VB Code:
    1. Imports System
    2. Imports System.ComponentModel
    3. Imports System.Drawing
    4. Imports System.Windows.Forms
    5.  
    6. Namespace Microsoft.Samples.WinForms.VB.SimpleHelloWorld
    7.  
    8.     Public Class SimpleHelloWorld
    9.          Inherits System.Windows.Forms.Form
    10.  
    11.         'Run the application
    12.         <STAThread()> Shared Sub Main()
    13.             System.Windows.Forms.Application.Run(New SimpleHelloWorld())
    14.         End Sub
    15.  
    16.         Public Sub New()
    17.             MyBase.New()
    18.             Me.Text = "Hello World"
    19.         End Sub
    20.     End Class
    21.  
    22. End Namespace

    In experimenting with it I found that you could remove
    "Imports System
    Imports System.ComponentModel
    Imports System.Drawing
    Imports System.Windows.Forms"

    and the programme would still work O.K. Can anyone tell me if there is any reason for including such apparently unnecessary code?


    Also, the following seems to be unnecessary:

    "Inherits System.Windows.Forms.Form" as

    "Inherits Form"

    appears to work perfectly O.K. (with or without the foregoing Imports)

    Finally, the following also appears to be unnecessary

    " <STAThread()> Shared Sub Main()"

    as

    " Shared Sub Main()"

    works O.K. on its own. Anyone know why Com interoperability is put here?

    Many thanks for any input.


    EDIT: I see my [VB Code] is not working. Anyone know why?
    Last edited by taxes; Mar 8th, 2004 at 03:59 PM.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    you have to use [vbcode/] without any space...


    Umm I think they import the System namespace because a lot of the basic stuff that you will end up using in your app is in the System namespace and so this way yuo dont have to type System.Blah blah everytime....

    Forms works same as System.Windows.Forms.Form becauses of this import statement: Imports System.Windows.Forms That basically means that you can access anything in that namespace without having to type the whole thing every time. Why do they put the compelete thing? eeh I dont know, I guess just because it's probably to point out where exactly they are inheriting from, dunno really

    umm and I dont know what statThread does
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi MrPolite,

    So, none of it is necessary? Yet Microsoft are teaching this for experienced programmers new to VB.NET!!


    "umm and I dont know what statThread does"

    It introduces COM interopability, but I see no need for it in the sample they used. It allows you to use DAO and ADO amongst other things.


    Many thanks.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  4. #4
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well yeah it's not necessary but I guess they always put it there just to make it more clear... you may wanna ask some more advanced users here, because I'm not officially a programmer, at least not yet
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210
    bleh. i think it'd be better to start out with not using those. do it the harder way (well not necessarily in all cases but in this case) and when you get better take the shortcuts. that's my thinking.

    you can just ignore me. i don't know much about programming or vb.net anyway. just learning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width