Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
这个鱼和熊掌不可得兼的经验,收藏!
有一按钮“编号”:自觉效率不高,能优化?
Dim str As String
For Each dr As DataRow In DataTables("申请表").DataRows
str = "[乡名] = '" & dr("乡名") & "'And [村名] = '" & dr("村名") & "' And [组别] = '" & dr("组别") & "'"
str = str & "And [单位(个人)] = '" & dr("单位(个人)") & "' And [法定代表人] = '" & dr("法定代表人") & "' And [_Identify] < " & dr("_Identify")
dr("宗地序号") = Format(Tables("申请表").Compute("Count(乡名)",str)+1,"00")
Next
Tables("申请表").Sort = "法定代表人 DESC" '降序排列
添加到集合再对比,真是高。受用了。
顶!试试去
有一按钮“编号”:自觉效率不高,能优化?
Dim str As String
For Each dr As DataRow In DataTables("申请表").DataRows
str = "[乡名] = '" & dr("乡名") & "'And [村名] = '" & dr("村名") & "' And [组别] = '" & dr("组别") & "'"
str = str & "And [单位(个人)] = '" & dr("单位(个人)") & "' And [法定代表人] = '" & dr("法定代表人") & "' And [_Identify] < " & dr("_Identify")
dr("宗地序号") = Format(Tables("申请表").Compute("Count(乡名)",str)+1,"00")
Next
Tables("申请表").Sort = "法定代表人 DESC" '降序排列
可以这么改改看看:
Dim str As String
Dim Dic As New Dictionary(of DataRow, String)
For Each dr As DataRow In DataTables("申请表").DataRows
str = "[乡名] = '" & dr("乡名") & "'And [村名] = '" & dr("村名") & "' And [组别] = '" & dr("组别") & "'"
str = str & "And [单位(个人)] = '" & dr("单位(个人)") & "' And [法定代表人] = '" & dr("法定代表人") & "' And [_Identify] < " & dr("_Identify")
dic.Add(dr,Format(DataTables("申请表").Compute("Count(乡名)",str)+1,"00"))
Next
For dr As DataRow In dic.Keys
dr("宗地序号") = dic(dr)
Next
可以这么改改看看:
Dim str As String
Dim Dic As New Dictionary(of DataRow, String)
For Each dr As DataRow In DataTables("申请表").DataRows
str = "[乡名] = '" & dr("乡名") & "'And [村名] = '" & dr("村名") & "' And [组别] = '" & dr("组别") & "'"
str = str & "And [单位(个人)] = '" & dr("单位(个人)") & "' And [法定代表人] = '" & dr("法定代表人") & "' And [_Identify] < " & dr("_Identify")
dic.Add(dr,Format(DataTables("申请表").Compute("Count(乡名)",str)+1,"00"))
Next
For dr As DataRow In dic.Keys
dr("宗地序号") = dic(dr)
Next
这都看不出来吗,我手误而已, 应该是:
For Each dr As DataRow In dic.keys