Using List.Find in VB.NET

I have two columns. One column contains string values, and the other column contains decimal values. I want to select a decimal value by selecting a string value.

string decimal Jewel 10 Hasan 20 

How to choose a Jewel to return 10?

+6
source share
3 answers

Try the following:

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

Or, if you need the first appearance of Jewel, use this:

 Dim selectedValue As InvoiceSOA selectedValue = DisputeList.Find(Function(p) p.ColumnName = "Jewel") 
+19
source
 Dim selectedValue As InvoiceSOA = DisputeList.Find(Function(p) if p.ColumnName = "Jewel" then return true end if end function) 
0
source

Enum functionality is the right way to use for this issue.

Example:

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

How to use this 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 
0
source

All Articles