|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
下列一段代码 运行VS 2010编写,比相同的代码直接在VBA中运行慢很多,求哪位大侠告知原因?
Sub fx()
Dim i, j, k, ILS, ils1, ils2, pyz, gsl10(9) As Integer
Dim CURZ, CURJG, tpc(2), STRJG, strgsm9, tempstr, twszhc As String
Dim wszhfx(99, 10), kjhm(6) As Integer
Globals.Sheet1.Activate()
Globals.Sheet1.Cells(5, 10) = Now
i = 21
Do While Globals.Sheet1.Cells(i, 1).value2 > 0
For j = 0 To 9
gsl10(j) = 0
If j > 2 Then kjhm(j - 3) = Globals.Sheet1.Cells(i, j).value2
Next j
STRJG = ""
CURZ = ""
CURJG = ""
strgsm9 = ""
pyz = 12
twszhc = ""
For j = 0 To 4
For k = j + 1 To 5
STRJG = STRJG & (kjhm(j) Mod 10) & (kjhm(k) Mod 10) & "|"
ILS = ((kjhm(k) - kjhm(j) - 1) Mod 10) * 10 + (kjhm(j) Mod 10)
If wszhfx(ILS, 0) > 0 Then Globals.Sheet1.Cells(i - 1, pyz + ILS) = wszhfx(ILS, 0)
If wszhfx(ILS, 0) < 10 Then
gsl10(wszhfx(ILS, 0)) = gsl10(wszhfx(ILS, 0)) + 1
Else
ils2 = Int(wszhfx(ILS, 0) / 10)
strgsm9 = strgsm9 & Chr(64 + ils2) & (wszhfx(ILS, 0) Mod 10)
End If
Globals.Sheet1.Cells(i, pyz + ILS) = Chr(65 + Int((kjhm(k) - kjhm(j) - 1) / 10)) & IIf(wszhfx(ILS, 0) = 0, wszhfx(ILS, 10), wszhfx(ILS, 9) & "|" & wszhfx(ILS, 7) + 1)
Globals.Sheet1.Cells(i, pyz + ILS).Interior.ColorIndex = IIf(Chr(65 + Int((kjhm(k) - kjhm(j) - 1) / 10)) = Left(Globals.Sheet1.Cells(i - wszhfx(ILS, 0) - 1, pyz + ILS).value2, 1), 4, 37)
If InStr(1, CURZ, Format(ILS, "00")) > 0 Then twszhc = twszhc & "#" & (kjhm(j) Mod 10) & (kjhm(k) Mod 10) & Format(wszhfx(ILS, 0), "00")
CURZ = CURZ & Format(ILS, "00") & "|"
Next k
Next j
Globals.Sheet1.Cells(i, 10) = STRJG
Globals.Sheet1.Cells(i, 11) = CURZ
tempstr = ""
ILS = 0
For j = 0 To 9
tempstr = tempstr & j & gsl10(j) & "|"
If j < 5 Then ILS = ILS + gsl10(j)
Next j
ils1 = Len(strgsm9) / 2
Globals.Sheet1.Cells(i, 113) = tempstr
Globals.Sheet1.Cells(i, 114) = strgsm9
Globals.Sheet1.Cells(i, 115) = ILS & "|" & (15 - ILS - ils1) & "|" & ils1
Globals.Sheet1.Cells(i, 116) = twszhc
Call fxcx(wszhfx, CURZ, "", tpc, CURJG, i)
Globals.Sheet1.Cells(i, 112) = CURJG
i = i + 1
Loop
Call Showhzjg(i, pyz, wszhfx)
Globals.Sheet1.Cells(6, 10) = Now
end sub |
|