想问个代码优化的问题
vb.net吧
全部回复
仅看楼主
level 11
情义灬情 楼主
Dim i, j, m, n, nlr4, nlr2, ds As Integer
nlr2 = xlsheet2.Cells.SpecialCells(11).Row
nlr4 = xlsheet4.Cells.SpecialCells(11).Row
Dim strcode, strcust, strdate, x, y, z As String
' Dim dt As Date
For i = 1 To nlr2
For m = 1 To nlr4
strcode = "XCODE" + xlsheet2.Cells(i, 1).value.ToString
strcust = "YCUST" + xlsheet2.Cells(i, 4).value.ToString
strdate = "ZZZZZ" + xlsheet2.Cells(i, 2).value.ToString
If strcode = xlsheet4.Cells(m, 1).value.ToString Then
x = xlsheet4.Cells(m, 2).value
For j = m To nlr4
If strcust = xlsheet4.Cells(j, 1).value Then
y = xlsheet4.Cells(j, 2).value
For n = j To nlr4
If strdate = xlsheet4.Cells(n, 1).value Then
ds = n + x + y
z = xlsheet4.Cells(ds, 1).value.ToString.Replace("ZZZZZ", "")
' dt = z
xlsheet2.Cells(i, 5).value = z '.ToString("yyyyMMdd")
Else
End If
Next n
End If
Next j
End If
Next m
Next i
2013年12月05日 01点12分 1
level 11
情义灬情 楼主
主要功能是打开两个excel,然后对比,从excel1中得到的一个数据,到excel12种对比,但是要在excel2种找3个数据,就是代码中的strcode, strcust, strdate三个变量。
我现在这样写的时间复杂度太大了,想请教哪位给优化下算法,降低时间复杂度。谢谢!
2013年12月05日 01点12分 2
level 13
据说把next后面的字母去掉能快一点
--来自可以用水果刀发帖的 诺基亚 Lumia 625H
2013年12月09日 05点12分 3
请教下能快多少? 还有就是能不能有其他的算法。给个思路也可以!
2013年12月09日 05点12分
回复 情义灬情 :看着怪怪的,用字符串标记你需要的单元格,处理完再还原。。。为什么不一次性解决呢?
2013年12月09日 12点12分
1