VBScriptを使用したプログラミング中、関数がアクションを開始する前に、関数に多くのエラーチェックコードを記述します。したがって、いくつかの前提条件が満たされない場合は、「ExitFunction」を実行します。したがって、たとえば:
public fucnton func
if not condition then
func = -1
exit function
End If
'Other conditions with exit functions
'Then long code goes here
..........
..........
..........
func = res
End Function
だから、私は複数のポイントで機能を終了することができます。これは良い方法ですか?この場合、ifステートメントのelseブランチが長くなります
多分それは書く方が良いです:
public fucnton func
if not condition then
func = -1
Else
'Then long code goes here
..........
..........
..........
End If
End Function
あなたの考えを共有してください。