入力した月のパラメーターを特定の形式に変換する関数を作成しました。たとえば、04を関数に渡した場合、関数は「_APR_」を返します。私が書いた関数は次のようなものです。
function GetEnMonth()
{
param([string] $month)
switch ($month)
{
($_ -eq "01"){$result = "_JAN_"}
($_ -eq "02"){$result = "_FEB_"}
($_ -eq "03"){$result = "_MAR_"}
($_ -eq "04"){$result = "_APR_"}
($_ -eq "05"){$result = "_MAY_"}
($_ -eq "06"){$result = "_JUN_"}
($_ -eq "07"){$result = "_JUL_"}
($_ -eq "08"){$result = "_AUG_"}
($_ -eq "09"){$result = "_SEP_"}
($_ -eq "10"){$result = "_OCT_"}
($_ -eq "11"){$result = "_NOV_"}
($_ -eq "12"){$result = "_DEC_"}
default {$result ="_No_Result_"}
}
return [string]$result;
}
次に、以下のコマンドを使用して関数を実行し、結果を取得します。
$mYear = $today.substring(0,4)
$mMonth =$today.substring(4,2)
$mDate = $today.substring(6,2)
$monthInEn = GetEnMonth $mMonth
ええと、結果は常に「_No_Result_」です、なぜですか?以下は例外です:
**** Exception type : System.Management.Automation.RuntimeException
**** Exception message : You cannot call a method on a null-valued expression.
誰かが私にこれに対する答えを与えることができますか?私はグーグルをたくさん検索しましたが、有用な解決策を見つけられません。