有沒有更好的方法來處理嵌套的else if語句有不同的結果?替代嵌套Else如果語句的結果不同?
這裏是我的嵌套語句的一個解釋的例子:
If My.Computer.Network.Ping(computerName) = True Then
Call InstallVS(computerName)
If My.Computer.Network.Ping(computerName) = True Then
Call PEC(computerName)
If My.Computer.Network.Ping(computerName) = True Then
Call RemoveSoftware(computerName)
Else
Call WriteLog(computerName & " lost connectivity while attemping to remove the temp software")
End If
Else
Call WriteLog(computerName & " lost connectivity while Forcing Communication")
End If
Else
Call WriteLog(computerName & " lost connectivity while attemping to Install")
End If
我有很多這些類型的報表的要求,一些比較小的,有些是很多大。
注意,在你的程序中的消息不與在此期間,你失去了連接的動作相對應。它顯示了您想要顯示的動作之後的動作。下面的答案給出了正確的結果,因爲在執行操作之前建立了消息文本,而您的操作在執行後會在 – Martin 2012-02-21 13:58:58