実現したいこと
Powershellのfor文でテキストボックスを複数作成して取り扱う。
発生している問題・分からないこと
Powershellのfor文でテキストボックスを複数作成した際、Form上には出力されているが値を参照しようとしても取得できない。
該当のソースコード
Powershell
1Add-Type -AssemblyName System.Windows.Forms 2Add-Type -AssemblyName System.Drawing 3 4$form = New-Object System.Windows.Forms.Form 5$form.Text = 'Data Entry Form' 6$form.Size = New-Object System.Drawing.Size(300,200) 7$form.StartPosition = 'CenterScreen' 8 9$Button = New-Object System.Windows.Forms.Button 10$Button.Location = New-Object System.Drawing.Point(75,120) 11$Button.Size = New-Object System.Drawing.Size(75,23) 12$Button.Text = 'OK' 13$Button.DialogResult = [System.Windows.Forms.DialogResult]::OK 14$form.AcceptButton = $Button 15$form.Controls.Add($Button) 16 17for($i=1; $i -le 5; $i++){ 18$textBox = 'textbox' + $i 19${$textBox} = New-Object System.Windows.Forms.TextBox 20${$textBox}.Location = New-Object System.Drawing.Point(10*$i,40*$i) 21${$textBox}.Size = New-Object System.Drawing.Size(260,20) 22$form.Controls.Add(${$textBox}) 23} 24 25$form.Topmost = $true 26$form.ShowDialog() 27 28$Button.add_click{ 29 [System.Windows.Forms.MessageBox]::Show($textbox1.Text + $textbox2.Text + $textbox3.Text + $textbox4.Text + $textbox5.Text) 30}
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
「powershell オブジェクト 自動採番」で検索してみましたが解決しませんでした。
補足
特になし

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。