2011-08-23 86 views
0

內的枚舉值我試過下面的代碼,但它始終沒有返回,它應該進入搜索枚舉

Protected Function GetTotalDebitAmount(ByRef roEntryDetailRecordBaseList As List(Of PPDEntryDetailRecord)) As String 
    Dim iTotal As Integer = 0 
    If Me.BatchHeaderRecord.ServiceClassCode = Convert.ToString(CInt(ServiceClassCodes.EntriesMixedDebitsAndCredits)) Then 
     For Each oEntryDetailRecord As PPDEntryDetailRecord In roEntryDetailRecordBaseList 
      If CBool(Array.IndexOf([Enum].GetValues(GetType(TransactionCodes.Debits)), CInt(oEntryDetailRecord.TransactionCode)) > 0) Then 
       iTotal += CInt(oEntryDetailRecord.Amount) 
      End If 
     Next 
    End If 

    Return CStr(iTotal) 
End Function 

我需要一個誰評估以下部分:

If CBool(Array.IndexOf([Enum].GetValues(GetType(TransactionCodes.Debits)), CInt(oEntryDetailRecord.TransactionCode)) > 0) Then 

謝謝。

+0

我所要做的就是'Enum.IsDefined()'方法:) – Tarik

回答

0

不管怎麼說,

我已經找到了答案:

If [Enum].IsDefined(GetType(TransactionCodes.Debits), CInt(oEntryDetailRecord.TransactionCode)) Then 
        iTotal += CInt(oEntryDetailRecord.Amount) 
End If