VB 6 to VB.net converion form event behavioral problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Developer111
    New Member
    • Apr 2010
    • 28

    VB 6 to VB.net converion form event behavioral problem

    Hi,

    I am using VS 2008 conversion wizard to convert a VB6 project to VB.net 2008. I have encountered a problem in the converted VB.net project. The Load event of a ‘form’ is not rising (in a specific scenario) in the converted VB.net version in comparison to the previous (VB6) implementation. The problem scenario is when I call a subroutine “SetLabelPos()” in ‘form1’ from ‘MainForm’:

    Form1.SetLabelP os()

    In this function I set position of label on form1:

    Label1.Top = 350

    When this line executes it raises the load event of form1 (in VB6 and not in VB.net), which performs some lengthy tasks and then returns control to the next line in “SetLabelPos” subroutine.

    I have attached a sample VB6 project with this post, which demonstrates the scenario. I need reasoning (as why the same code acts differently in .net version i.e. Load event of the form is not raised) and work around for this situation.

    Thanks

    Hassan
    Attached Files
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    From MSDN documentation:

    [Form.Load Event] occurs before a form is displayed for the first time.
    It sounds like what you were depending on was a side-effect of the behavior of VB 6, specifically that handling a displayable object caused the containing form to be loaded.

    If what you are after is doing some expensive initialization, then you could try explicitly calling a method that performs that initialization (besides load). It would give you finer control over when that code gets executed.

    Comment

    Working...