' used to replace the datatable.getvalues method, because foxtable has bugs
Dim DT As DataTable = args(0)
Dim ColName As String = args(1)
Dim FilterStr As String =""
Dim SortStr As String=""
If args.count >2 Then
FilterStr = args(2)
End If
If args.count>3 Then
SortStr = args(3)
End If
If DT Is Nothing OrElse ColName=Nothing Then
Return Nothing
End If
If dt.DataRows.count = 0 Then Return Nothing
'***************************************************************************************************
If SortStr = "" Then SortStr = ColName & " asc" ' default sort ascending
'***************************************************************************************************
'先排序datatable
Dim NDT As system.data.DataTable = DT.basetable
Dim dv = ndt.DefaultView
dv.Rowfilter = filterStr
dv.Sort = sortstr
Dim dtCopy As system.data.DataTable = dv.ToTable
'***************************************************************************************************
try
Dim dic As new Dictionary (of String, Integer) (StringComparer.OrdinalIgnoreCase) ' ignore case
For i As Integer =0 To dtCopy.Rows.count-1
Dim str As String = dtCopy.Rows(i)(ColName)
If dic.ContainsKey(str) =False Then
dic.add(str,i)
End If
Next
Dim Ks As new List (of String)
For Each kk As String In dic.keys
ks.add(kk)
Next
Return ks
catch ex As exception
Return False '在上一层触发错误,以便上层catch可以捕捉到
End try