- ©«¤l
- 835
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 915
- ÂI¦W
- 16
- §@·~¨t²Î
- Win 10,7
- ³nÅ骩¥»
- 2019,2013,2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-3
- ³Ì«áµn¿ý
- 2024-11-14
|
¥»©«³Ì«á¥Ñ luhpro ©ó 2016-4-22 23:35 ½s¿è
¦^´_ 9# chaoyiho
©êºp,²{¦b¤~¦³®É¶¡¦^¤å.
§Ú¤§©Ò¥H·|§â vD ªº©w¸q©ñ¦b Module ¤W,
ì¥ýªººc·Q¬O¸ê®ÆÀÉ®×´N¨º¤@Ó,
¨º»ò¶}©l®É´NŪ¨ú¤@¦¸,
¦r¨å«Ø¦n«á±¥un®³¨Ó¥Î´N¦n¤F,
¤£¥Î¨C«ö¤@¦¸«ö¶s´N¤Sn«·sŪ¨úÀɮפΫإ߹ïÀ³¸ê®Æ.
²ßºD©ÊªºÂI¨â¤U "¶}±ÒÂÂÀÉ" «ö¶s¶}±Ò CommandButton1_Click ¹ê°µ¦Û¤vªººc·Q,
¦]¬°¦^¤å«á¤~µo²{³B²z "±z¨S¦³¶}±Ò¥ÀÀÉ" ªº Sub ¦³¦n´XÓ, O.O"
©È·|»P¤§«eµ²ªG«Å|¤~·|¥[¨º¤@¦æ®ø°£«e¤â.
¦Ü©ó§Aµo¥Íªº°ÝÃD,
§Ú¦b³o¨âÓÀɮ׶¡¾Þ§@¨Ã¤£·|µo¥Í,
¦]¬° RemoveAll ¥u²M°£ Key »P ¸ê®Æ ¶¡ªº¹ïÀ³Ãö«Y,
¨Ã¤£·|§R°£ vD ¦r¨åª«¥ó.
¬ã§P¥i¯à¬O¾Þ§@¤¤µ{¦¡¥ý«á¶¶§Ç°ÝÃD,
¾ÉP§A¨S¦³°õ¦æ¨ì Set vD = CreateObject("Scripting.Dictionary").
¦ÓÃö©ó°ÝÃDªº³B²z:
¦b 10# ªº¬O¤@ºØ²³æ©úÁAªº³B²z¤èªk.
¤£¹L¨ÌÓ¤H¤§«eªº¸gÅç,
¤]¦³¥i¯à¬OÓ¤H¥\¤O¤Ó®t,
§Úµo²{ Excel ¤W¨Ã¤£¯à¥Î¤@Ó Is Nothing ´N¥]¿ì©Ò¦³³oÃþª«¥ó¿ù»~ªº§PÂ_,
¦]¬°³o¤@¦æ«ü¥O¤]¥i¯à·|¥X²{¿ù»~(¦]¬°³s vD ³oÓª«¥ó³£¤£¯à¥X²{¦b§PÂ_¦¡¤¤)
¥t¦³¤@ӫܦh¤H¨Ï¥Îªº³B²z¤èªk,
´N¬O¤@¶}©l´N¥[Ó On Error Resume Next,
³o¼Ë¹J¨ì¿ù»~´N·í°µ¨S°ÝÃDµo¥ÍÄ~Äò¶]¤U¥h,
¹B®ð¦n´N¨S¨Æ...
¦ýn¬O¹B®ð¤£¦nªº¸Ü...
¤ñ¸û¥¿²Î¥B¤£©ö¥X²{«D¹w´Áµ²ªGªº°µªk¬O°w¹ï¿ù»~°µ±Mªùªº³B²z. (½Ð·j´M On Error ³¯z¦¡ ªº»¡©ú)
Sub ChkFile()
...
On Error GoTo ErrorHandler ' ¶}±Ò¿ù»~³B²zµ{¦¡¡C
vD.RemoveAll ' µo¥Í¿ù»~»Ý°µ³B²zªºµ{¦¡
On Error Goto 0 ' Ãö³¬¿ù»~³B²zµ{¦¡¡C
...
Exit Sub ' Â÷¶}µ{¦¡¡A¥HÁקK¶i¤J¿ù»~³B²zµ{¦¡¡C
ErrorHandler: ' ¿ù»~³B²zµ{¦¡¡C
Select Case Err.Number ' Àˬd¿ù»~¥N½X¡C
Case 424 ' µo¥Í¡u¦¹³B»Ýnª«¥ó¡v¤§¿ù»~¡C
Set vD = CreateObject("Scripting.Dictionary") ' «Ø¥ßª«¥ó¡C(°w¹ï¿ù»~µo¥Íì¦]°µ¸É±Ï©Î³B²z)
Case Else ' ¥Î Err.number ¨ú±o¿ù»~¥N½X, ¥Î Err.Description ¨ú±o¿ù»~»¡©ú¤å¦r. Err.Clear ²M°£¿ù»~ºX¼Ð
MsgBox Prompt:=Err.Description, Buttons:=vbOK, Title:="µo¥Í¿ù»~"
Err.Clear
Exit Sub
End Select
Resume ' ±Nµ{¦¡°õ¦æ¨BÆJ¦^¨ììµo¥Í¿ù»~ªº³¯z¦¡¤¤¡C
End Sub
¥t¥~, °w¹ï«½Æ¥B¥i´À¥Nªºµ{§Ç«Øij¥t«Ø¥ß°Æµ{¦¡¥H¨Ñ©I¥s, ¦p:
Image22_Click
Image3_Click
Image32_Click()
CommandButton1_Click()
CommandButton10_Click()
CommandButton14_Click()
CommandButton6_Click()
ªº¤º®e¥þ³¡³£¬O :
If Application.FindFile = False Then
MsgBox "±z¨S¦³¶}±Ò¥ÀÀÉ"
End If
¨º´N¥i¥H§â³o¬qÂk¨ì Module ¤º, ³]¬° Public, ¦AÓ§O©ñ¤J©I¥s«ü¥O§Y¥i.
¦n³B¬Oµ{¦¡½X®e©öקï»PºÞ²z, ÁYµuµ{¦¡½X, ¿ëÃѫפ]¸û¦n.- Public Sub ChkFile()
- If Application.FindFile = False Then
- MsgBox "±z¨S¦³¶}±Ò¥ÀÀÉ"
- End If
- Dim lRow&
-
- lRow = 3
-
- On Error GoTo ErrorHandler ' ¶}±Ò¿ù»~³B²zµ{¦¡¡C
- vD.RemoveAll
- EXCELªí³æ³B²z¤¶±.ListBox1.Clear ' ²M°£ ListBox ªº¿ï³æ
- On Error GoTo 0 ' Ãö³¬¿ù»~³B²zµ{¦¡¡C
-
- While Cells(lRow, 1) <> ""
- If Not vD.Exists(CStr(Cells(lRow, 1))) Then
- EXCELªí³æ³B²z¤¶±.ListBox1.AddItem CStr(Cells(lRow, 1))
- vD(CStr(Cells(lRow, 1))) = lRow
- End If
- lRow = lRow + 1
- Wend
- Exit Sub ' Â÷¶}µ{¦¡¡A¥HÁקK¶i¤J¿ù»~³B²zµ{¦¡¡C
- ErrorHandler: ' ¿ù»~³B²zµ{¦¡¡C
- Select Case Err.Number ' Àˬd¿ù»~¥N½X¡C
-
- Case 424 ' µo¥Í¡u¦¹³B»Ýnª«¥ó¡v¤§¿ù»~¡C
- Set vD = CreateObject("Scripting.Dictionary") ' «Ø¥ßª«¥ó¡C
-
- Case Else ' ¥i¥Î Err.number ¨ú±o¿ù»~¥N½X, ¥Î Err.Description ¨ú±o¿ù»~»¡©ú¤å¦r. Err.Clear ²M°£¿ù»~ºX¼Ð
- MsgBox prompt:="¿ù»~¥N½X : " & Err.Number & Chr(10) & "¿ù»~ì¦]:" & Err.Description, Buttons:=vbOK, Title:="µo¥Í¿ù»~"
- Err.Clear
- Exit Sub
- End Select
- Resume ' ±Nµ{¦¡°õ¦æ¨BÆJ¦^¨ììµo¥Í¿ù»~ªº³¯z¦¡¤¤¡C
-
- End Sub
½Æ»s¥N½X- Private Sub CommandButton1_Click()
- ChkFile
- End Sub
½Æ»s¥N½X ¾lÃþ±À.
ªí³æ³B²z¨t²Î3.2(PLS)-a2.zip (631.5 KB)
|
|