|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- 'n个数求连号的通用代码(用字典)
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- For i = 3 To r
- m = 0: L = 7 '定义中奖号任意长度(个数)
- For j = 2 To L
- m = m + 1
- If arr(i, j) = arr(i, j - 1) + 1 Then
- d(arr(i, j) - m & n) = m + 1
- Else
- m = 0: n = n + 1
- End If
- Next
- For Each n2 In d.items
- If arr(i, 8) = "" Then
- arr(i, 8) = n2
- Else
- arr(i, 8) = arr(i, 8) & " + " & n2
- End If
- Next
- d.RemoveAll: n = 0: n2 = 0
- Next
-
- 'n个数求连号的通用代码
- For i = 3 To r
- L = 7 '定义中奖号任意长度(个数)
- ReDim brr(1 To L): ReDim crr(1 To L): m = 0: n = 0
- For j = 1 To L
- m = m + 1
- For k = j + 1 To L
- n = n + 1
- If crr(k) = 168 Then Exit For
- If arr(i, j) + n = arr(i, k) Then
- brr(m) = n + 1: crr(k) = 168 '标志不重复访
- Else
- Exit For
- End If
- Next: n = 0
- Next
- For j = 1 To L
- If brr(j) <> 0 Then
- If arr(i, 9) <> "" Then
- arr(i, 9) = arr(i, 9) & " + " & brr(j)
- Else
- arr(i, 9) = brr(j)
- End If
- End If
- Next
- Next
复制代码 |
|