Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Basic VB question?

Options
  • 24-05-2001 1:10pm
    #1
    Moderators, Science, Health & Environment Moderators Posts: 8,843 Mod ✭✭✭✭


    I'm a great one for not knowing the basic methods in VB. Been working on a system at work for a while now and have come across a problem. It's an MDI app with about 3/4 child forms.
    I have code for the load and resize events of these children and it seems that sometimes switching from one to another under certain circumstances can cause the program to go into a loop between 2 or 3 of the forms, constantly trying to show each one. This seems to be caused because the resize event fires when you hide as well as when you show.
    The code on the menu of the MDI parent to switch to each form is:-

    ActiveForm.hide
    frmAccoutnDets.show

    In this case where frmAccountDets would be the form to switch to. I'm wondering is their some standard code I should use for switching between children in an MDI app and what is the standard form event to place code in that will be allowed to manipulate controls within it. i.e. the load event does not seem to allow setfocus if you are switching to another form immediately after. all a bit messy and annoying but this is what I get for teaching myself and not learning the basics.

    M


Comments

  • Closed Accounts Posts: 1,322 ✭✭✭phobos


    Hi,

    I did not think that the resize event would be triggered if you simply show/hide a form. I would expect it to be triggered post the load event, but not unless the user resized it or you explicitly set the forms width/height in the code (probably what;s wrong).

    I don't know what code you have behind the resize event of the MDI children, but I am sure it is here the problem lies. Another thing to remember is to **avoid duplicate code**. This kind of thing could be leading to one form performing an action, passing context to another and the other executing the same code which in turn.........and so on.

    I will gladly take a look at any other code you wish to show, if you think it will define your problem a bit better.

    :-phobos-)


  • Moderators, Science, Health & Environment Moderators Posts: 8,843 Mod ✭✭✭✭mewso


    Thanks I seem to have fixed it. The resize code is necessary to rearrange controls on a form so they still appear on the form when a user resizes it.
    The initialisation stuff I have put in the activate event for the forms and they are checked so that they only run once, the first time. With all this it seems o.k. so I'm keeping my fingers crossed.

    M


Advertisement