Speed up GUI Builder programs by not using GSet command when not needed.

Sometimes we see customers doing code similar to the following:

If newStatus = 0 Then

   GSet Test.CheckBox1.Checked, False


   GSet Test.CheckBox1.Checked, True


The problem with this code is that it will do a GSet for the checkbox every single time even if the setting hasn’t changed.  So for example, if newStatus is 0 and CheckBox1 is unchecked, it will set that again.  That is a wasted GSet and GSet does take some time to perform. 

A better example would be to do it more like this:


GGet Test.CheckBox1.Checked, prevStatus

If newStatus <> prevStatus Then

   If newStatus = 0 Then

      GSet Test.CheckBox1.Checked, False


      GSet Test.CheckBox1.Checked, True



With this example, if the current state of the checkbox is already the same as it would be set to, it skips the GSet commands.  In general, especially in programs where there is a main loop that refreshes the GUI screen, you want to make sure you are not doing completely unneeded GSets.

You can also use variables to track the current status of a GUI item each time it changes and then simply read the variable to determine if a GSet is needed.  The only caveat there is that the code has to be accurate and always updating the variable correctly.

Related Articles

No related articles were found.


No attachments were found.

Visitor Comments

Article Details

Last Updated
19th of December, 2014

Would you like to...

Print this page  Print this page

Email this page  Email this page

Post a comment  Post a comment

 Subscribe me

Subscribe me  Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Quick Edit

Export to PDF

User Opinions

No users have voted.

How would you rate this answer?

Thank you for rating this answer.