9

我有两列。一列包含字符串值,另一列包含十进制值。我想通过选择字符串值来选择十进制值。

string          decimal
Jewel           10
Hasan           20

如何选择 Jewel,使其返回 10?

4

3 回答 3

39

试试这个:

Dim selectedValues As List(Of InvoiceSOA)
selectedValues = DisputeList.FindAll(Function(p) p.ColumnName = "Jewel")

或者,如果您需要第一次出现“Jewel”,请使用:

Dim selectedValue As InvoiceSOA
selectedValue = DisputeList.Find(Function(p) p.ColumnName = "Jewel")
于 2013-02-04T07:17:01.210 回答
0
Dim selectedValue As InvoiceSOA = DisputeList.Find(Function(p) 
        if p.ColumnName = "Jewel" then
            return true
        end if
    end function)
于 2014-11-23T01:39:40.453 回答
0

枚举功能是解决这个问题的正确方法。

例子:

Public Enum Ornaments
    Neclace = 10
    Bangle = 20
    TieClip = 30
End Enum

如何使用这个枚举

Dim SelectedOrnament As Ornaments = Ornaments.Bangle

Select Case SelectedOrnament

    Case Ornaments.Neclace
        MsgBox("Your ornament is: " & Ornaments.Neclace)

    Case Ornaments.Bangle
        MsgBox("Your ornament is: " & Ornaments.Bangle)

    Case Ornaments.TieClip
        MsgBox("Your ornament is: " & Ornaments.TieClip)

    Case Else
        MsgBox("I could not find your ornament. Sorry")

End Select
于 2015-07-01T11:08:35.250 回答