Goodmorning,
I've found a script that creates a simple form, but there was 1 thing missing and that was a radiobutton\checkbox.
So I add a radio button in to the script. But i can't figure out how to see if the button was checked at the end of the script.
This code if($radiobutton.checked){write-host "button pressed"} only works if its in the script it self. I can't use in a new part of a if statement (end of the script) Is it possible to check at the end of the if the button was checked or not?
function button ($title,$a1,$a2,$a3) {
###################Load Assembly for creating form & button######
[void][System.Reflection.Assembly]::LoadWithPartialName( “System.Windows.Forms”)
[void][System.Reflection.Assembly]::LoadWithPartialName( “Microsoft.VisualBasic”)
#####Define the form size & placement
$form = New-Object “System.Windows.Forms.Form”;
$form.Width = 500;
$form.Height = 305;
$form.Text = $title;
$form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen;
############################################Label 1 ############################################
##############Define text label1
$textLabel1 = New-Object “System.Windows.Forms.Label”;
$textLabel1.Left = 25;
$textLabel1.Top = 15;
$textLabel1.Height = 65;
$textLabel1.Width = 140;
$textLabel1.Text = $a1;
############Define text box1 for input
$textBox1 = New-Object “System.Windows.Forms.TextBox”;
$textBox1.Left = 170;
$textBox1.Top = 55;
$textBox1.width = 280;
############################################Label 2 ############################################
##############Define text label2
$textLabel2 = New-Object “System.Windows.Forms.Label”;
$textLabel2.Left = 25;
$textLabel2.Top = 95;
$textLabel2.Width = 140;
$textLabel2.Height = 100;
$textLabel2.Text = $a2;
############Define text box2 for input
$textBox2 = New-Object “System.Windows.Forms.TextBox”;
$textBox2.Left = 170;
$textBox2.Top = 140;
$textBox2.width = 40;
############################################Radio 1 ############################################
##############Define text label1
$textLabel3 = New-Object “System.Windows.Forms.Label”;
$textLabel3.Left = 25;
$textLabel3.Top = 215;
$textLabel3.Height = 65;
$textLabel3.Width = 140;
$textLabel3.Text = $a3;
############Define text box1 for input
$radio1 = New-Object “System.Windows.Forms.RadioButton”;
$radio1.Left = 170;
$radio1.Top = 210;
#############Define default values for the input boxes
$defaultValue = “”
$textBox1.Text = $defaultValue;
$textBox2.Text = $defaultValue;
$radio1.Text = 'Ja';
#############define OK button
$button = New-Object “System.Windows.Forms.Button”;
$button.Left = 380;
$button.Top = 240;
$button.Width = 100;
$button.Text = “Ok”;
############# This is when you have to close the form after getting values
$eventHandler = [System.EventHandler]{
$textBox1.Text;
$textBox2.Text;
$radio1.Text
$form.Close();};
$button.Add_Click($eventHandler) ;
#############Add controls to all the above objects defined
$form.Controls.Add($button);
$form.Controls.Add($textLabel1);
$form.Controls.Add($textLabel2);
$form.Controls.Add($textLabel3);
$form.Controls.Add($textBox1);
$form.Controls.Add($textBox2);
$form.Controls.Add($radio1);
$ret = $form.ShowDialog();
#################return values
return $textBox1.Text, $textBox2.Text, $radio1.Text
}
$return=
button “Create New Order Folders” "Specify the folder path(s)
----------------------------
Example:030\1\1DD00046" "Extra A8 Folders.
----------------------------
Example: if total is 12 folders then type 7(12-5) because of the 5 A8 which are already there or when it is 12 EXTRA Folders, then type 12" "Create extra A8 Folders"