- test.zip
- (25.73 KiB) Downloaded 153 times
Progressbar visible set to false when sub form is loaded
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Progressbar visible set to false when sub form is loaded
- Attachments
-
- test.zip
- (25.73 KiB) Downloaded 128 times
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Progressbar visible set to false when sub form is loaded
It is never necessary to mess with scopt when calling between scrips and funcitons. Just pass the object.
in mainform
in mainform
PowerShell Code
Double-click the code block to select all.$button1_Click = { Call-sub_psf $progressbar1 }In child form:
PowerShell Code
Double-click the code block to select all.Param($pb) $form1_Load={ $pb.Visible=$false }That is all and it was what I meant when I said use arguments.
Re: Progressbar visible set to false when sub form is loaded
You guys have to be kidding, it is so simple.
Thank you dan.potter and jvierra
Works perfectly
Thank you dan.potter and jvierra
Works perfectly
- dan.potter
- Posts: 709
- Last visit: Wed Nov 14, 2018 11:39 am
Re: Progressbar visible set to false when sub form is loaded
What is the drawback of changing the scope?jvierra wrote:It is never necessary to mess with scopt when calling between scrips and funcitons. Just pass the object.
in mainformPowerShell Code
Double-click the code block to select all.$button1_Click = { Call-sub_psf $progressbar1 }In child form:
PowerShell Code
Double-click the code block to select all.Param($pb) $form1_Load={ $pb.Visible=$false }That is all and it was what I meant when I said use arguments.
Re: Progressbar visible set to false when sub form is loaded
Harder to maintain. Less readable. Exposes variables to being clobbered.dan.potter wrote:
What is the drawback of changing the scope?
Scoping should always be as narrow as possible. The whole point of passing arguments is to avoid exposure. In programming we pursue a policy of maximum "data hiding".
New programmers tend to make this mistake due to lack of experience and because it is an easy fix.
Think of the thing those new to Windows admin do which is to make everyone an admin. It takes some time too learn how to get the job done without creating issues.