1
我需要下面的帮助;需要将文本框中的值转换为整数
这是CMD-让
Set-Datastore [-Datastore] <Datastore[]> [[-Name] <String>] [-CongestionThresholdMillisecond <Int32>]
我将与 '-CongestionThresholdMillisecond' 参数一起使用一个文本框。我已经厌倦了不同的方式,但要么不能将字符串转换为int或者值小于5(不允许)。
$textBox417.Size = New-Object Drawing.Size (80,30)
$textBox417.Location = New-Object System.Drawing.Size (100,140)
$int = $textBox417.Value.ToString()
$button = New-Object System.Windows.Forms.Button
$button.Size = New-Object Drawing.Size (110,30)
$button.Location = New-Object System.Drawing.Size (50,180)
$button.add_click({Set-Datastore -Name $label438.Text -CongestionThresholdMillisecond $int})
非常感谢!
我第一次尝试,它似乎传递0。设置的数据存储:无法验证的参数变量“CongestionThresholdMillisecond”。 0参数小于允许的最小值 的范围5.提供大于5的参数,然后再次尝试该命令。 – Shamza 2013-03-21 17:16:29
在将它传递给命令之前打印$ int,是否获得与文本框中相同的值? – 2013-03-21 17:22:29
如上所述得到'0'。即使尝试'$ int = $ textBox417.value -as [int]'仍然会得到0. – Shamza 2013-03-21 17:34:52