- ©«¤l
- 228
- ¥DÃD
- 73
- ºëµØ
- 2
- ¿n¤À
- 333
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 10
- ³nÅ骩¥»
- Office 2000, 2019
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¹ü¤Æ¿¤
- µù¥U®É¶¡
- 2013-7-18
- ³Ì«áµn¿ý
- 2024-10-13
|
¤À¨Éì³Ð¥N½X¡]¤£³ß¤¤¤å¥N½X¡A½Ð¦Û¦æÂন^¤å¡^
----------------------------------------------------------
S_¨Ì¦Ûq²M³æéw±Æ§Ç¼Ò²Õ_01.bas
----------------------------------------------------------
Option Explicit
Public Sub S_¤@ºû°}¦C¨Ì¦Ûq²M³æéw±Æ§Ç_01(ByRef ì©l¤@ºû°}¦C As Variant, ByVal °_ As Long, ByVal ¨´ As Long, ByVal ¦Ûq²M³æ°}¦C As Variant)
On Error Resume Next
If °_ >= ¨´ Then
Exit Sub
End If
'------------------------------------------------------
Dim X As Long
Dim ¯Á¤Þ°}¦C() As Long
'------------------------------------------------------
ReDim ¯Á¤Þ°}¦C(°_ To ¨´) As Long
'------------------------------------------------------
¤@ºû°}¦C¨Ì¦Ûq²M³æéw±Æ§Ç ì©l¤@ºû°}¦C, ¯Á¤Þ°}¦C, °_, ¨´, ¦Ûq²M³æ°}¦C
'------------------------------------------------------
Dim ½Æ»sì©l¤@ºû°}¦C As Variant
½Æ»sì©l¤@ºû°}¦C = ì©l¤@ºû°}¦C
For X = °_ To ¨´
ì©l¤@ºû°}¦C(X) = ½Æ»sì©l¤@ºû°}¦C(¯Á¤Þ°}¦C(X))
Next X
End Sub
Public Sub S_¤Gºû°}¦C¨Ì¦Ûq²M³æéw±Æ§Ç_01(ByRef ì©l¤Gºû°}¦C As Variant, ByVal ±Æ§Çºû«× As Long, ByVal ±Æ§ÇÁäÈ As Long, ByVal °_ As Long, ByVal ¨´ As Long, ByVal ¦Ûq²M³æ°}¦C As Variant)
On Error Resume Next
If °_ >= ¨´ Then
Exit Sub
End If
'------------------------------------------------------
Dim X As Long
Dim Y As Long
Dim Â^¨ú¦¨¤@ºû°}¦C As Variant
Dim ¯Á¤Þ°}¦C() As Long
'------------------------------------------------------
ReDim Â^¨ú¦¨¤@ºû°}¦C(°_ To ¨´) As Variant
ReDim ¯Á¤Þ°}¦C(°_ To ¨´) As Long
If ±Æ§Çºû«× = 1 Then
For X = °_ To ¨´
Â^¨ú¦¨¤@ºû°}¦C(X) = ì©l¤Gºû°}¦C(X, ±Æ§ÇÁäÈ)
Next X
Else
For Y = °_ To ¨´
Â^¨ú¦¨¤@ºû°}¦C(Y) = ì©l¤Gºû°}¦C(±Æ§ÇÁäÈ, Y)
Next Y
End If
'------------------------------------------------------
¤@ºû°}¦C¨Ì¦Ûq²M³æéw±Æ§Ç Â^¨ú¦¨¤@ºû°}¦C, ¯Á¤Þ°}¦C, °_, ¨´, ¦Ûq²M³æ°}¦C
'------------------------------------------------------
Dim ½Æ»sì©l¤Gºû°}¦C As Variant
½Æ»sì©l¤Gºû°}¦C = ì©l¤Gºû°}¦C
If ±Æ§Çºû«× = 1 Then
For X = °_ To ¨´
For Y = LBound(ì©l¤Gºû°}¦C, 2) To UBound(ì©l¤Gºû°}¦C, 2)
ì©l¤Gºû°}¦C(X, Y) = ½Æ»sì©l¤Gºû°}¦C(¯Á¤Þ°}¦C(X), Y)
Next Y
Next X
Else
For Y = °_ To ¨´
For X = LBound(ì©l¤Gºû°}¦C, 1) To UBound(ì©l¤Gºû°}¦C, 1)
ì©l¤Gºû°}¦C(X, Y) = ½Æ»sì©l¤Gºû°}¦C(X, ¯Á¤Þ°}¦C(Y))
Next X
Next Y
End If
End Sub
Private Sub ¤@ºû°}¦C¨Ì¦Ûq²M³æéw±Æ§Ç(ByRef ì©l¤@ºû°}¦C As Variant, ByRef ¯Á¤Þ°}¦C() As Long, ByVal °_ As Long, ByVal ¨´ As Long, ByVal ¦Ûq²M³æ°}¦C As Variant)
On Error Resume Next
Dim X As Long
Dim N As Long
'------------------------------------------------------
Dim ¦Ûq²M³æ¦r¨å As Object
Set ¦Ûq²M³æ¦r¨å = CreateObject("Scripting.Dictionary")
For X = LBound(¦Ûq²M³æ°}¦C) To UBound(¦Ûq²M³æ°}¦C)
¦Ûq²M³æ¦r¨å(¦Ûq²M³æ°}¦C(X)) = 0
Next X
¦Ûq²M³æ°}¦C = ¦Ûq²M³æ¦r¨å.Keys
'------------------------------------------------------
For X = °_ To ¨´
If ¦Ûq²M³æ¦r¨å.Exists(ì©l¤@ºû°}¦C(X)) = True Then
¦Ûq²M³æ¦r¨å(ì©l¤@ºû°}¦C(X)) = ¦Ûq²M³æ¦r¨å(ì©l¤@ºû°}¦C(X)) + 1
¯Á¤Þ°}¦C(X) = ¦Ûq²M³æ¦r¨å(ì©l¤@ºû°}¦C(X))
Else
¦Ûq²M³æ¦r¨å("Key_Not_Exist") = ¦Ûq²M³æ¦r¨å("Key_Not_Exist") + 1
¯Á¤Þ°}¦C(X) = ¦Ûq²M³æ¦r¨å("Key_Not_Exist")
End If
Next X
'------------------------------------------------------
Dim ¦Ûq²M³æ²Ö¿n¼Æ°}¦C As Variant
Dim ¦Ûq²M³æ²Ö¿n¼Æ¦r¨å As Object
¦Ûq²M³æ²Ö¿n¼Æ°}¦C = ¦Ûq²M³æ¦r¨å.Items
Set ¦Ûq²M³æ²Ö¿n¼Æ¦r¨å = CreateObject("Scripting.Dictionary")
¦Ûq²M³æ²Ö¿n¼Æ¦r¨å(¦Ûq²M³æ°}¦C(0)) = 0
N = 0
For X = 1 To UBound(¦Ûq²M³æ°}¦C)
¦Ûq²M³æ²Ö¿n¼Æ¦r¨å(¦Ûq²M³æ°}¦C(X)) = ¦Ûq²M³æ²Ö¿n¼Æ°}¦C(N)
N = N + 1
¦Ûq²M³æ²Ö¿n¼Æ°}¦C(N) = ¦Ûq²M³æ²Ö¿n¼Æ°}¦C(N - 1) + ¦Ûq²M³æ²Ö¿n¼Æ°}¦C(N)
Next X
¦Ûq²M³æ²Ö¿n¼Æ¦r¨å("Key_Not_Exist") = ¦Ûq²M³æ²Ö¿n¼Æ°}¦C(N)
'------------------------------------------------------
For X = °_ To ¨´
If ¦Ûq²M³æ¦r¨å.Exists(ì©l¤@ºû°}¦C(X)) = True Then
¯Á¤Þ°}¦C(X) = ¯Á¤Þ°}¦C(X) + ¦Ûq²M³æ²Ö¿n¼Æ¦r¨å(ì©l¤@ºû°}¦C(X))
Else
¯Á¤Þ°}¦C(X) = ¯Á¤Þ°}¦C(X) + ¦Ûq²M³æ²Ö¿n¼Æ¦r¨å("Key_Not_Exist")
End If
Next X
'------------------------------------------------------
Dim ¯Á¤Þ°}¦C°Æ¥» As Variant
¯Á¤Þ°}¦C°Æ¥» = ¯Á¤Þ°}¦C
For X = °_ To ¨´
¯Á¤Þ°}¦C(°_ - 1 + ¯Á¤Þ°}¦C°Æ¥»(X)) = X
Next X
End Sub |
|