2015-04-06 32 views
0

我在「End Function」下面有一個綠色的波形,它會提示我,並說「你是否缺少返回語句?」當我確實有一個回報聲明。以下是我有:End Function在所有代碼路徑上不返回值

Private Function TaxCalcFunc(ByVal propVal As Decimal, ByVal perc As Decimal, ByVal rate As Decimal) As Decimal 
    Dim AssessedValue As Decimal 
    Dim Tax As Decimal 
    Try 
     AssessedValue = propVal * perc 
     Tax = AssessedValue/100 * rate 
     Return Tax 
     If rate > 1 Or perc > 1 Then 
      Throw New Exception("Tax Greater Than Value. Did you use the decimal Point?") 
     End If 

    Catch ex As Exception 
     MessageBox.Show(0) 

    End Try 
    'I was unable to get rid of the green squiggle for some reason, says I am missing a return statement 
End Function 

回答

0

你沒有return語句內或Catch語句後,所以如果一個例外是Return Tax代碼之前拋出,則你的函數將確實沒有返回值。

相關問題