Dim dc as notesdocumentcollection
dim rsdoc as notesdocument
Set dc=Mdoc.responses
If dc.count>0 then
For i=1 to dc.count
set rsdoc=dc.getNthdocument(i)
print rsdoc.域(0)
next
end if
这样找出来的值是按创建日期的先后顺序排序。怎么办?
...全文
394打赏收藏
怎样对一个文档的所有文档按某个域的值排序?55555555555555555
Dim dc as notesdocumentcollection dim rsdoc as notesdocument Set dc=Mdoc.responses If dc.count>0 then For i=1 to dc.count set rsdoc=dc.getNthdocument(i) print rsdoc.域(0) next end if 这样找出来的值是按创建日期的先后顺序排序。怎么办?
子函数:
Sub OrderDc(dc As notesdocumentcollection,order() As Integer)
total=dc.count
If total=1 Then
Redim order(1)
order(1)=1
Exit Sub
End If
Dim k As Integer
Dim kk As Integer
Dim tempdoc As notesdocument
Dim banhao() As String
Redim order(1 To total) As Integer
Redim bianhao(1 To total) As String
For k=1 To total
Set tempdoc=dc.getnthdocument(k)
If tempdoc.form(0)="yjjg" Or tempdoc.form(0)="ejjg" Or tempdoc.form(0)="sjjg" Or tempdoc.form(0)="SIjjg" Then
If tempdoc.danweibianma(0)="" Or Len(tempdoc.danweibianma(0))<>9 Then
bianhao(k)=99999999
Else
bianhao(k)=tempdoc.danweibianma(0)
End If
Else
bianhao(k)=tempdoc.renyuanbianhao(0)
End If
order(k)=k
Next
For k=1 To total-1
For kk=k+1 To total
If Trim(bianhao(k))>Trim(bianhao(kk)) Then
temp=bianhao(k)
bianhao(k)=bianhao(kk)
bianhao(kk)=temp
temp1=order(k)
order(k)=order(kk)
order(kk)=temp1
End If
Next
Next
End Sub
主函数中的调用:
dim rsdoc as notesdocument
dim dc as notesdocumentcollection
dim rsdoc as notesdocument
Set dc=Mdoc.responses
If dc.count>0 Then
Dim order() As Integer
Call OrderDc(dc,order())
For j= 1 To dc.count
Set rsdoc=dc.getnthdocument(order(j))
//your code
.......
next
end if