Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

variable does not exist outside of Event Handler

$
0
0

I found am example of how to return a value from a Windows form and believe there is a bug or I just don't understand how it should work... The specific line that doesn't work for me is this:

In this example they set $X to a value from the Text box, and at the end of the script they output the text that was entered as part of the $ObjTextbox object. The output of $X never happens for me. The only way I have gotten this to work is to change $X to $Global:X... Is the example wrong, or is there something I am missing.

$OKButton.Add_Click({$x=$objTextBox.Text;$objForm.Close()})


I got the example from here:

http://technet.microsoft.com/en-us/library/ff730941.aspx





Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>