2011-03-07 39 views
2

我想输出在文本框中输入的值到使用PowerShell的HTML,但我有点卡住了。这里是我的代码:转换为HTML与Powershell问题

$button1 = New-Object System.Windows.Forms.Button 
$button1.Name = "button1" 
$button1.Location = New-Object System.Drawing.Point(16, 350) 
$button1.Text = "Create" 
$button1.add_Click({ConvertTo-HTML -title "Email Signature" -body "<p>$textBox2.Text</p>"}) 

产生的HTML是...

System.Windows.Forms.TextBox, Text: Chris.Text 

我怎样才能使输出仅仅是 “Chris”?

+0

工作了:)答案是:$($ textBox2.Text) – cvandal 2011-03-07 01:43:49

回答

0

工作了:)

答案是:$($ textBox2.Text)

0

你可以用变量在任一()或{}封闭在 “当检索值”。

例如,

$button1.add_Click({ConvertTo-HTML -title "Email Signature" -body "<p>$($textBox2.Text)</p>"}) 

$button1.add_Click({ConvertTo-HTML -title "Email Signature" -body "<p>${textBox2.Text}</p>"})