試す:
do{
$opgegevenGetal = read-host "Enter an integer"
$a = ""
if( ![int32]::TryParse( $opgegevenGetal , [ref]$a ))
{
write-host "Only integers please"
}
} until ($a -gt 0)
入力として受け入れるためのコード0
:
do{
$opgegevenGetal = read-host "Enter an integer"
$a = ""
if( ![int32]::TryParse( $opgegevenGetal , [ref]$a ))
{
write-host "Only integers please"
}
} until ($a -gt 0 -or $opgegevenGetal -eq '0')
また:
do{
$opgegevenGetal = read-host "Enter an integer"
$a = ""
$b = [int32]::TryParse( $opgegevenGetal , [ref]$a )
if( !$b)
{
write-host "Only integers please"
}
} until ($b)