ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] «ç»ò¦bUSERFORM¤¤¥[¤J¥i¿z¿ï½Æ¿ï¤§¾ðª¬¹Ï

¦^´_ 9# chaoyiho

§A¦b¼Ò²Õ1 (Module1) ¥[¤J¤F Public vD
ªº«Å§i«á¡A¨Ã©ó Workbook_Open() ¸Ì
³]©w¤F  vD ªºÄÝ©Ê¡A°ò¥»¤W«K OK ¤F¡C
©¹«áµ{¦¡½X¤§°õ¦æ§¡¯à¦Û°Ê¿ë»{¥¦¤F¡C

TOP

¦^´_ 9# chaoyiho
§Ú¨Ï¥Î DEBUG MODE Æ[¹î¡A·|²£¥Í§ä¤£¨ìª«¥óªº¨Æ¹ê¡A
¬G­×§ï¦¨¦p¤U¡G

¸Õ¸Õ¬Ý¡I

TOP

¥»©«³Ì«á¥Ñ 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«á­±¥u­n®³¨Ó¥Î´N¦n¤F,
¤£¥Î¨C«ö¤@¦¸«ö¶s´N¤S­n­«·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.
  1. Public Sub ChkFile()
  2.     If Application.FindFile = False Then
  3.         MsgBox "±z¨S¦³¶}±Ò¥ÀÀÉ"
  4.     End If

  5.     Dim lRow&
  6.    
  7.     lRow = 3
  8.    
  9.     On Error GoTo ErrorHandler    ' ¶}±Ò¿ù»~³B²zµ{¦¡¡C
  10.     vD.RemoveAll
  11.     EXCELªí³æ³B²z¤¶­±.ListBox1.Clear ' ²M°£ ListBox ªº¿ï³æ
  12.     On Error GoTo 0    ' Ãö³¬¿ù»~³B²zµ{¦¡¡C
  13.    
  14.     While Cells(lRow, 1) <> ""
  15.       If Not vD.Exists(CStr(Cells(lRow, 1))) Then
  16.         EXCELªí³æ³B²z¤¶­±.ListBox1.AddItem CStr(Cells(lRow, 1))
  17.         vD(CStr(Cells(lRow, 1))) = lRow
  18.       End If
  19.       lRow = lRow + 1
  20.     Wend
  21. Exit Sub        ' Â÷¶}µ{¦¡¡A¥HÁקK¶i¤J¿ù»~³B²zµ{¦¡¡C

  22. ErrorHandler:    ' ¿ù»~³B²zµ{¦¡¡C
  23.     Select Case Err.Number    ' Àˬd¿ù»~¥N½X¡C
  24.    
  25.         Case 424    ' µo¥Í¡u¦¹³B»Ý­nª«¥ó¡v¤§¿ù»~¡C
  26.             Set vD = CreateObject("Scripting.Dictionary") ' «Ø¥ßª«¥ó¡C
  27.             
  28.         Case Else   ' ¥i¥Î Err.number ¨ú±o¿ù»~¥N½X, ¥Î Err.Description ¨ú±o¿ù»~»¡©ú¤å¦r. Err.Clear ²M°£¿ù»~ºX¼Ð
  29.             MsgBox prompt:="¿ù»~¥N½X : " & Err.Number & Chr(10) & "¿ù»~­ì¦]:" & Err.Description, Buttons:=vbOK, Title:="µo¥Í¿ù»~"
  30.             Err.Clear
  31.             Exit Sub
  32.     End Select
  33.     Resume    ' ±Nµ{¦¡°õ¦æ¨BÆJ¦^¨ì­ìµo¥Í¿ù»~ªº³¯­z¦¡¤¤¡C
  34.    
  35. End Sub
½Æ»s¥N½X
  1. Private Sub CommandButton1_Click()
  2.   ChkFile
  3. End Sub
½Æ»s¥N½X
¾lÃþ±À.

ªí³æ³B²z¨t²Î3.2(PLS)-a2.zip (631.5 KB)

TOP

¦^´_ 13# luhpro

¤j¤j»¡ªº "§Úµo²{ Excel ¤W¨Ã¤£¯à¥Î¤@­Ó Is Nothing ´N¥]¿ì©Ò¦³³oÃþª«¥ó¿ù»~ªº§PÂ_"

¦pªG§â Public vD  §ï¦¨ Public vD  as object

ÁÙ·|¥X²{  Is Nothing  µo¥Í°ÝÃD¶Ü

ÆZ¦n©_ªº

¦pªG¬O¥Î Public vD  
¤£¥Î On Err ¥i¥H¼g¦¨
if  isObject( vD )  then
    if   vD  is Nothing  then
    end if
end if

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-4-23 07:31 ½s¿è

¦^´_ 14# jackyq
©ú½Tªº«Å§iÅܼƫ¬ºA ,¥i¨Ïµ{¦¡½X¤£©ö¥X¿ù,¥B®e©ö°»¿ù
  1. Option Explicit
  2. Dim vD 'As Object
  3. Sub Ex()
  4.     '¦p Dim vD  »Ý¦³°õ¦æ Ex1«á¦A°õ¦æ Ex
  5.     '¦p¬O Dim  vD  As Object ´N¤£»Ý¥ý°õ¦æ Ex1
  6.     MsgBox vD Is Nothing  'Dim vD  µ{¦¡°õ¦æ¿ù»~¤F   
  7.     Set vD = Nothing
  8.     MsgBox vD Is Nothing
  9.     If vD Is Nothing Then
  10.         Set vD = CreateObject("Scripting.Dictionary")
  11.     End If
  12.     End   'µ²§ô©Ò¦³ªºµ{§Ç°õ¦æ
  13. End Sub
  14. Sub Ex1()
  15.     MsgBox IsObject(vD)
  16.     If Not IsObject(vD) Then
  17.         Set vD = CreateObject("Scripting.Dictionary")
  18.     End If
  19.     MsgBox vD Is Nothing
  20.     'End
  21. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 15# GBKEE


    http://forum.twbts.com/redirect. ... 0&fromuid=21301

§Ú¦³§ï¥¿©ã   cc....

TOP

¦^´_ 14# jackyq
¶â...
¦]¬°§Ú¤j³£¬O¬Ý¤pÀ°¤â»P¥»¯¸¦Û¾Ç,
¦³®É¦£¨S¬Ý¨ìªº°Q½×¦ê´N¥u¯à¿ù¥¢¾Ç²ß¤F,

¦b¤pÀ°¤â¸Ìªº»¡©ú:
Dictionary ª«¥ó
  ´y­z
ª«¥ó¡A¥Î©óÀx¦s¸ê®ÆÃöÁä¦r©M¶µ¥Ø¹ï¡C
»yªk
Scripting.Dictionary
½Ðª`·N
Dictionary ª«¥ó»P PERL ¬ÛÃö°}¦C¥þµ¥¡C¥i¥H¬O¥ô¦ó«¬¦¡ªº¸ê®Æªº¶µ¥Ø³QÀx¦s¦b°}¦C¤¤¡C¨C­Ó¶µ¥Ø³£»P¤@­Ó°ß¤@ªºÃöÁä¦r¬ÛÃö¡C¸ÓÃöÁä¦r¥Î¨Ó¨ú¥X³æ­Ó¶µ¥Ø¡A³q±`¬O¾ã¼Æ©Î¦r¦ê¡A¥i¥H¬O°£°}¦C¥~ªº¥ô¦ó«¬ºA¡C
¤U­±ªºµ{¦¡½XÁ|¨Ò»¡©ú¤F¦p¦ó«Ø¥ß¤@­Ó Dictionary ª«¥ó¡G

Dim d                   '«Ø¥ß¤@­ÓÅܼÆ
Set d = CreateObject(Scripting.Dictionary)
d.Add "a", "Athens"     '¥[¤J¤@¨ÇÃöÁä¦r©M¶µ¥Ø
d.Add "b", "Belgrade"d.Add "c", "Cairo"
...


©Ò¥H,§Ú¤@ª½¾Ç¨ìªº³£¬O Dictionary ª«¥ó­n¥Î Variant ¸ê®Æ«¬ºA ¨Ó«Å§i,
¦­¥ý¬°¤F¸Ñ¨MÃþ¦üªº¿ù»~, Is Nothing, Is Null, = Null, .... ¸Õ¤F¤@°ï¤èªk¯Ó®É®À§é,
«á¨Ó¨Ä¨Äªº¥Î ¿ù»~³B²zµ{¦¡ ³B²z¤~¶¶§Q,
ÁÂÁ¤À¨É«ü¥¿.

TOP

¦^´_ 13# luhpro

©êºp«e½ú¡A¨ì²{¦b¤~¦^
¨º¬O¦]¬°§Ú¤@ª½·Q­n±N±zªºÁ¿¸Ñtry¥X¨Ó¤§«á¦A¦^³ø§Úªº°ÝÃD»Pµo²{
¥i¬O§Úµo²{§Ú·d¤F´X¤ÑÁÙ¬O¨S¯àtry¥X¨Ó...
¯uªº¬O¯à¤O«D±`¤£¨¬
©Ò¥H¤µ¤Ñ¥[¯Z°È¥²§Æ±æ¥i¥H¬ã¨s¥X¨Ó!!

¥[¤W§Ú¦]¬°Åv­­ªºÃö«YµLªk¤U¸üªþÀÉ
½Ð°Ý«e½ú¥i¥H±NÀÉ®×±H¨ì§Úªº«H½c¶Ü?
Åý§Ú¦³­Ó°Ñ¦Ò..
§Úªº«H½c¬O:
[email protected]

¬ã¨s±z»¡ªº³o¨Ç µ²ªG¤@­Ó³£¨S¦³¸Õ¥X¨Ó ¤@ª½¥X²{¿ù»~
§Ú·Qµ´¹ï¬O¦]¬°§Úªºµ{¦¡½X¶K¿ù¦a¤è
¦]¬°¬Oªì¾ÇªÌªºÃö«Y
©Ò¥H¸ê®Æ¯S§O²V¶Ã
¤µ¤Ñ¥f°_¨Ó§âµ{¦¡½X³q³q°µ¤@­Ó¾ã²z
²{¦bµ{¦¡½X¤w¸g°µ¦n¤ÀÃþ ÁöµMÁÙ¬O«ÜÃ÷ªø...

§Úªº°ÝÃD¥D­n¦³¨â­Ó
1.¹Á¸Õ«e½ú¤W­±ªºµ{¦¡½X ¥i¯à¦]¬°¤£ª¾¹D¸Ó©ñ­þÃä¦Ó³y¦¨¿ù»~¶i¦ÓµLªk°õ¦æ
2.Ãö©ó­«½Æ°Ê§@ªºµ{¦¡½XÁY´î

·PÁ«e½ú­ÌªºÀ°¦£!!

TOP

¦^´_ 15# GBKEE

·PÁª©¥D!!
¨º¦A½Ð°Ýª©¥D ½Ð°Ý±z³o­Óµ{¦¡½Xªº·N¸q¸Õ«ç»ò¤@­ÓÅÞ¿è©O?
§Æ±æ¥i¥H°w¹ï³o¼Ëªºµ{¦¡½X¸Ó©ñ¦b­þ¸Ì°µ«Å§i»Pµ{¦¡½X¤º®e°µ­ÓÁ¿¸Ñ
§Ú¯uªº«Ü§Æ±æ¥i¥H¾Ç·|
¦A¦¸ÁÂÁª©¥D!!

TOP

¦^´_ 12# c_c_lai

·PÁÂcc¤jªº¦^ÂÐ
§Ú¦³¹Á¸Õ·ÓµÛ±zªº«ü¥Ü­×§ï
¦ý¬O«o·|µo²{¥X²{¤@­Ó·s°ÝÃD
activeX ¿ù»~
Google¤F¤@¤U
§Ú«o¬Ý¤£À´³o¨ì©³¬OÄÝ©ó¤@­Ó¤°»ò¼ËªºªF¦è
¹Á¸Õ¨ì¤u¨ã¦C¤¤´M§ä³o­Óªþ¥ó ¦ý¬O§Ú§ä¤£¨ì
½Ð°Ý³o¬O¤°»ò°ÝÃD©Ò¾É­P
§Ú¤S¸Ó«ç»ò¸Ñ¨M©O?

TOP

        ÀR«ä¦Û¦b : ºÉ¦h¤Ö¥»¥÷¡A´N±o¦h¤Ö¥»¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD