Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Form Load Runs Events

Form Load Runs Events

Scheduled Pinned Locked Moved Visual Basic
questionvisual-studio
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BobbyStrain
    wrote on last edited by
    #1

    I have a windows application with lots of controls that are set with initial values. When the form loads, execution occurs about a dozen times. How can I stop this execution on form load? I am using VS 2010. Bobby

    Richard Andrew x64R 1 Reply Last reply
    0
    • B BobbyStrain

      I have a windows application with lots of controls that are set with initial values. When the form loads, execution occurs about a dozen times. How can I stop this execution on form load? I am using VS 2010. Bobby

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Define "execution".

      The difficult we do right away... ...the impossible takes slightly longer.

      B 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        Define "execution".

        The difficult we do right away... ...the impossible takes slightly longer.

        B Offline
        B Offline
        BobbyStrain
        wrote on last edited by
        #3

        Richard, I have a sub in the form that does all the calculations for the form. Many of the controls will trigger it. I added a message box in the execution of this sub and it pops up a dozen times before I see the form. It's like all the controls change events are firing during the form load. Bobby

        Richard Andrew x64R 1 Reply Last reply
        0
        • B BobbyStrain

          Richard, I have a sub in the form that does all the calculations for the form. Many of the controls will trigger it. I added a message box in the execution of this sub and it pops up a dozen times before I see the form. It's like all the controls change events are firing during the form load. Bobby

          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          Create a module-level Boolean flag that keeps track of whether the form is loading for the first time. Before you set the controls to their initial values, set the flag to true. When you are done setting the controls to their initial values, set the flag to false. In your calculation sub, check the value of the flag for false before performing the calculations.

          The difficult we do right away... ...the impossible takes slightly longer.

          B 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Create a module-level Boolean flag that keeps track of whether the form is loading for the first time. Before you set the controls to their initial values, set the flag to true. When you are done setting the controls to their initial values, set the flag to false. In your calculation sub, check the value of the flag for false before performing the calculations.

            The difficult we do right away... ...the impossible takes slightly longer.

            B Offline
            B Offline
            BobbyStrain
            wrote on last edited by
            #5

            Thank you for your help. Now I can apply the fix to a number of other applications. Bobby

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups