我有两列。一列包含字符串值,另一列包含十进制值。我想通过选择字符串值来选择小数值。
string decimal
Jewel 10
Hasan 20
如何选择Jewel以便它返回10?
答案 0 :(得分:24)
试试这个:
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")
答案 1 :(得分:0)
Dim selectedValue As InvoiceSOA = DisputeList.Find(Function(p)
if p.ColumnName = "Jewel" then
return true
end if
end function)
答案 2 :(得分:0)
Enum功能是用于此问题的正确方法。
示例:
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