mardi 31 mai 2016

vb.net how to get a value with specific condition

Thanks in advance. I searched but still don't know how to write.

[premise] I got a DataView of a Table, and filtered and sorted it.

[Table] [After filtering, the table looks like this: ↓]1

I want to get the names under different condition. I wrote like this but it seems not correct.

If dv_Table1.Select("Code1 = '11'").Rows.Count > 0 Then
   drwWork.Item("Name") = dv_Table1.Item(0).Item("Name")

ElseIf dv_Table1.Select("Code1 = 12").Rows.Count > 0 Then
   drwWork.Item("Name") = dv_Table1.Item(0).Item("Name")
      If dv_Table1.Item(0).Item("Code2") = 1 Then
         drwWork.Item("Code") = Asterisk
      Else
      End If

Else
End If

My main goal is to get the different names according to different code 1. I sorted the table by Order as well. When the record number of [ code1 = 12, for example] is more than 2, I want to get the two names in order ASC.

The [ Item(0).Item("Name") ] part maybe incorrect I want to know the correct coding.

Thank you !

Aucun commentaire:

Enregistrer un commentaire