Results 1 to 10 of 10

Thread: For those like me who didn't know this before ;)

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    For those like me who didn't know this before ;)

    If you start your program with sub main (main not Main) then you will face strange behaviour. It's a known bug!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I tried both ways without any bugs!!
    VB became easier because its complier doesn't differentiate Case-state of code.No matter it's Lower or Upper Cases but C++ does.
    VB Code:
    1. Sub Main()
    2.         MsgBox("From Main Sub")
    3.     End Sub
    4.  
    5.     'Sub main()
    6.     'MsgBox("from main sub")
    7.     'End Sub

    Dunno if you are doing something else!!!

  3. #3
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What kind of strange behavior are we talking about?

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Try the following and see the result:

    VB Code:
    1. Sub main()
    2.  
    3.    Msgbox(Application.ProductName)
    4.  
    5. End sub

    and then try with Sub Main().

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I've even tried MAIN , absolutely gives no difference.

    ?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Well I dont know what you tried, but as far as i searched this is a known bug and happens in some methods and properties of System.Windows.Forms.Application class, and running before mentioned code with sub main not Main will resulat in the error:
    object refrecnce not set to an instance ....

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. 'I created a class (love classes) and pasted
    2.     'your code as follow :
    3.     Sub Main()
    4.         MsgBox(Application.ProductName)
    5.     End Sub
    6.  
    7.     'and
    8.  
    9.     'Sub main()
    10.     '   MsgBox(Application.ProductName)
    11.     'End Sub
    12.  
    13.     ' in a form I did this :
    14.     'Dim mymain As New Class1()
    15.     'mymain.main()
    16.  
    17.     'both gave the same results .
    18.     '   but if I did this:
    19.     '   Dim mymain As Class1
    20.     '   mymain.main()
    21.     'I get that stupid error so .
    22.     'the error explain itself .i.e you are trying to use the
    23.     'base class itself rather than dimming an object that holds
    24.     'its instance.
    25.     'I did all this , just to assure  myself ,there is no such error.

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Come on man!

    I said if you start your program with a Sub main in a module not calling that from a form when it is inside a class.

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    that error happen when while instantiating subs or func. so I tried that.

  10. #10
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    oh YOU ARE RIGHT. when I set the app startup from module and run the app , it fires the error.
    sorry for that.

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