¨D±Ð¦³ÃöUserForm¨Ï¥Î§¹«á¤£¦û°O¾ÐÅ骺²M°£¤èªk
- ©«¤l
- 132
- ¥DÃD
- 31
- ºëµØ
- 0
- ¿n¤À
- 167
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- Office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- Taipei
- µù¥U®É¶¡
- 2011-4-14
- ³Ì«áµn¿ý
- 2024-2-28
|
¨D±Ð¦³ÃöUserForm¨Ï¥Î§¹«á¤£¦û°O¾ÐÅ骺²M°£¤èªk
¦U¦ì«e½ú¡A¤£¦n·N«ä¡A¤Sn¨Óµo°Ý¤F
°²¦p§Ú¦Û¤v§@¤F¤@ÓUserForm1¦Ó¡An¶}±Òªº¥L¤èªk¤S¦³¤GºØ
¤èªk¤@¡G
Sub Test_1()
Dim AForm As UserForm1
Set AForm = New UserForm1
With AForm
.Show
End With
Unload AForm
Set AForm = Nothing
End Sub
¤èªk¤G
Sub Test_2()
UserForm1.Show
Unload UserForm1
End Sub
·Q½Ð±Ð¦U¦ì«e½úªº¬O¡G
¤@¡B¦b¤èªk¤@¤ºUnload AForm¡A³o®Éµøµ¡·|®ø¥¢¡A¦ý¬Oºâ¬O³s¦û¥Îªº°O¾ÐÅé³£²M±¼¤F¶Ü¡HÁÙ¬On¦A°õ¦æSet AForm = Nothing¤~·|²M±¼°O¾ÐÅé©O¡H
¤G¡B¥t¥~§Ún¬O¨S¦³°õ¦æUnload AForm¡A¥u°õ¦æSet AForm = Nothing¡A¦ü¥Gµøµ¡ÁÙ¦b¡A¦ý¬O²z½×¤W¨Ó»¡AForm¦û¥Îªº°O¾ÐÅéÀ³¸Ó
³Q²M±¼¤~¹ï
¤T¡B³o¤GºØ¤èªk¡A¦³¤°»òÀu¯ÊÂI¤§¤À§O¶Ü¡H |
|
clio
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 31
- ºëµØ
- 0
- ¿n¤À
- 167
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- Office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- Taipei
- µù¥U®É¶¡
- 2011-4-14
- ³Ì«áµn¿ý
- 2024-2-28
|
¦^´_ 4# jackyq
«e½úªº³oÓ¨Ò¤l¡A¸ÑÄÀªº«Ü²M·¡»¡¡A«e±¤TÓLoadForm1³£¬O«·sLoadForm1¡A©Ò¥H²ÎpUserForm2.Count³£¬°1
¦Ó«á¤TÓSet F1=New UserForm1¡A«h¬O«Ø¥ß¤F¥t¤@ÓUserForm1¡A©Ò¥HUserForm2.Count´N·|¦A¥[1
·PÁ«e½úªº¨Ò¤l |
|
clio
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 31
- ºëµØ
- 0
- ¿n¤À
- 167
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- Office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- Taipei
- µù¥U®É¶¡
- 2011-4-14
- ³Ì«áµn¿ý
- 2024-2-28
|
¦^´_ 3# stillfish00
·PÁ«e½úªº«ü¥¿¸ò»¡©ú¡AÅý§Ú§ó²M·¡ªº¤F¸Ñ¤F¤@¨Ç¨Æ¡A§Ú¥»¨Ó¬O¦Ò¼{«Ø¥ß¤@ӪťժºUserForm¡AµM«á¦A¥Î¤@ÓFunction¨Ó©I¥s¥¦¡A¦Ó©Ò¦³ªº¸ü¤J¸ê®Æ¡A¾e¨ú¦^Âиê®Æ³£¥Ñ³oÓFunction¨Ó³B²z¨ú±o¡A¦ÓFunction¤S¥i¥H¶Ç¦^¸ê®Æ¡A©Ò¥H§Ú´N¥i¥H±o¨ì¨Ï¥ÎªÌ¿ï¨úªº¸ê®Æ¬°¦ó¡A¦ÓFunction¤º¸ü¤Jªº¤@¨Ç°Ñ¼Æ¡A¥i¥H¨M©wListBoxªºÈ¡A»P¤@¨Ç¿ï¶µ°Ñ¼Æ¡A§Ú¤]¥´ºâÅý¥L¦¨¬°±j¨î¿ï¨ú¡A©Ò¥H·|¨ú®ø✕«öÁ䪺¥\¯à¡A¨Ï¥¦¥¢®Ä¡A¦]¬°¥Ø«e§Ú§ä¤£¨ì§ó¦nªº¤èªk¨ÓÅýUserFormµ²§ô«e¡A§â¨Ï¥ÎªÌ¿ï¨úªº¸ê®Æ¶Ç¥X¥X¨Ó¡A¥Ø«e¥u¯à¥ÎPublicÅܼƤ~¯à¹F¨ì¡A¦ý¬O§Ú¦³¨Ç¤£·Q³]³o¼Ë¦hPublic ÅܼơA©Ò¥H¤~·Q§ï¥Î¦¹¤@¤è¦¡¡C |
|
clio
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 31
- ºëµØ
- 0
- ¿n¤À
- 167
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- Office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- Taipei
- µù¥U®É¶¡
- 2011-4-14
- ³Ì«áµn¿ý
- 2024-2-28
|
¦^´_ 2# luhpro
·PÁ«e½úªº¸Ñ»¡¡A³oÓ¤Ó²M·¡¤F¡AÅý§Ú§ó²M·¡ªº©ú¥Õ¡ASet ªº·N¸q¡A·PÁ±z¡C |
|
clio
|
|
|
|
|
- ©«¤l
- 319
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 309
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- 2k
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2015-6-24
- ³Ì«áµn¿ý
- 2024-4-27
|
Set AForm = Nothing¡A¦ü¥Gµøµ¡ÁÙ¦b
¦]¬°µøµ¡ªº¥»Åé VB ÁÙ°½°½ºw«rµÛ¥L
©Ò¥H¤£·|³QÄÀ©ñ |
|
|
|
|
|
|
- ©«¤l
- 319
- ¥DÃD
- 6
- ºëµØ
- 0
- ¿n¤À
- 309
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- 2k
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2015-6-24
- ³Ì«áµn¿ý
- 2024-4-27
|
New ¥Î¨Ó²£¥Í¦hÓ¹ê¨Ò
Sub QX9650()
Load UserForm1
UserForm1.Caption = "Form_1"
UserForm1.Show 0
tt = tt + 30: UserForm1.Top = tt
MsgBox "Load Form x1 -> Form count " & UserForms.Count
Load UserForm1
UserForm1.Caption = "Form_2"
UserForm1.Show 0
tt = tt + 30: UserForm1.Top = tt
MsgBox "Load Form x2 -> Form count " & UserForms.Count
Load UserForm1
UserForm1.Caption = "Form_3"
UserForm1.Show 0
tt = tt + 30: UserForm1.Top = tt
MsgBox "Load Form x3 -> Form count " & UserForms.Count
Set F1 = New UserForm1
F1.Caption = "Form_111"
F1.Show 0
tt = tt + 30: F1.Top = tt
MsgBox "New Form x1-> Form count " & UserForms.Count
Set F2 = New UserForm1
F2.Caption = "Form_222"
F2.Show 0
tt = tt + 30: F2.Top = tt
MsgBox "New Form x2 -> Form count " & UserForms.Count
Set F3 = New UserForm1
F3.Caption = "Form_333"
F3.Show 0
tt = tt + 30: F3.Top = tt
MsgBox "New Form x3 -> Form count " & UserForms.Count
End
End Sub |
|
|
|
|
|
|
- ©«¤l
- 1018
- ¥DÃD
- 15
- ºëµØ
- 0
- ¿n¤À
- 1058
- ÂI¦W
- 0
- §@·~¨t²Î
- win7 32bit
- ³nÅ骩¥»
- Office 2016 64-bit
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ®ç¶é
- µù¥U®É¶¡
- 2012-5-9
- ³Ì«áµn¿ý
- 2022-9-28
|
¦^´_ 1# clio
Ó¤Hı±o unload ¬O¼g¦b form events(¦pclick) ¤ºnÃö³¬¡BÄÀ©ñ¦Û¤v³oÓªí³æ¥Îªº¡C
¦Ó¤£¬O¹³§A¼g¦b show ¤U±¡A§A³o¼Ë¼g¥i¯à·|¦³¤£¨}®ÄªG¡C
¨Ò¦p§Aªº¤èªk¤G¡A
¦pªG¦b UserForm_Initialize() ¥[¤@¦æ MsgBox "Hi"¡A§A²q¥¦·|³Q©I¥s´X¦¸?
µª®×¬O¨â¦¸!!
²Ä¤@¦¸¬Oµo¥Í¦b UserForm1.Show¡A¦]¬°«e±¨S©ú½T¼g¥X Load (³o¬O¤¹³\ªº)¡AVBA¦Û°ÊÀ°§Aload«Ø¥ßForm¡C
µM«á¦]¬°§A«öªí³æªº x Ãö³¬®É¡AUserForm1¤w¸gÄÀ©ñ±¼¤F¡A©Ò¥H·í§A°õ¦æ¨ì Unload UserForm1 ¡AVBA¤S¦Û°ÊÀ°§A«Ø¥ßForm¡A¦AÄÀ©ñ±¼¡C
¦Ó¤èªk¤@¡A¬O§â UserForm1·íª«¥óÃþ§O¥Î
§Úı±o§a¡A set ... = new ...¡A´N¬O¨ú¥N Load §@¥Î¡AUnload AForm§Ú¬O¤£ª¾¹D¦³¨S¦³®ÄªG¡C
ª«¥óªº°O¾ÐÅ餣¥Î¤ÓªÈµ²¡A¦L¶H¤¤ VBA À³¸Ó¬O±Ä¥Î garbage collector ¾÷¨î¡Apºâ¤Þ¥Î¦¸¼Æ (reference count)¡A·í¤Þ¥Î¦¸¼Æ¬°¹s´N·|§ä®É¾÷¦^¦¬°O¾ÐÅé¤F¡C
¬JµMAForm¬O°Ï°ìÅܼơAÂ÷¶}¨ºÓSub ´NÄÀ©ñ¤F(¤]´N¬O¤£¤Þ¥Î¤F)¡A³o¸Ì¬Æ¦Ü¥[¤£¥[Set AForm = Nothing³£µL©Ò¿×¡C
§Úªº¸Ü¡An¹À«ö¶s¤º°µ§¹¤@¨Ç¨Æª½±µ unload meÃö³¬µøµ¡¡An¹À´N³£¤£¥[ unload¡A¤â°Ê«öXÃö³¬µøµ¡¡C
¦³¿ù½Ð«ü¥¿³á~ |
|
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C
|
|
|
|
|
- ©«¤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-3-26 00:21 ½s¿è
¦^´_ 1# clio
¥H¤U¬O Excel VBA ªº»¡©ú :
¤@¯ë·í¨Ï¥Î Set ¨Ó¤Þ¥Îª«¥óµ¹ÅܼƮɡA
¨Ã«D½Æ»s¤@¥÷ª«¥óµ¹ÅܼơA
¦Ó¬O«Ø¥ß¤@¥÷¹ï¸Óª«¥óªº¤Þ¥Î¡C (µù : ³o¸Ì©Ò¿×ªº¤Þ¥Î, ³Ì²³æªº¨Ò¤l´N¬OExcel¬¡¶Ã¯¤¤¬YÓÀx¦s®æªº¦ì§}, ÂǥѳoÓ¦ì§}¥i¥H¤Þ¥Î¨ì<¨ú±o>¦¹Àx¦s®æªº¤º®e,¦r«¬...)
¶W¹L¤@Ó¥H¤Wªºª«¥óÅܼƥi¥H¤Þ¥Î¬Û¦Pªºª«¥ó¡C
¦]¬°ÅܼƬO¤Þ¥Î¸Óª«¥ó¡A
¦Ó¤£¬O¤Þ¥Î¸Óª«¥óªº½Æ»s«~¡A
¸Óª«¥óY§ïÅÜ¡A
«h©Ò¦³¤Þ¥Î¥¦ªºÅܼƤ]·|¸òµÛ§ïÅÜ¡C
µM¦Ó¡AY¦b Set ³¯z¦¡¤W¨Ï¥Î New ÃöÁä¦r¡A
«h·|¯uªº«Ø¥ß¸Óª«¥óªº°õ¦æÓÅé¡C (µù : ÁöµM«Ø¥ß¤F ¤@Óª«¥ó, ¸ÓÅܼƤ´µMÁÙ¬O¤@¥÷¹ï¸Óª«¥óªº¤Þ¥Î)
©Ò¥H Set AForm = Nothing ¨ä¹ê¥u¬O²MªÅ¸ÓÅÜ¼Æ (¥¢¥h¤Þ¥Î¥\¯à),
§¹¥þ¨S¦³°Ê¨ì¸Óª«¥óªº¥»Åé.
¦Ü©ó Unload ªº»¡©ú :
±N¤@Óª«¥ó¦Û°O¾ÐÅ餤²¾°£¡C
ÅU¦W«ä¸q.
¨ä¹ê°£«D¦bµ{¦¡°õ¦æ¹Lµ{¤¤¤~°ÊºA«Ø¥ßª«¥ó,
§_«h·í¶}±ÒÀɮ׫á°O¾ÐÅ餺´N¤w¦s¤F¤@¥÷¸Óª«¥óªº¸ê®Æ¤F.
³Ì²³æªºÅçÃҤ覡 -
¶}±ÒExcel ¦sÀÉ«¶}¬Ý¬Ý¨Ï¥Îªº°O¾ÐÅéªÅ¶¡¶q,
±µµÛ¥[ÓUserForm«á¦sÀÉ«¶}¦A¬Ý¬Ý¨Ï¥ÎªºªÅ¶¡¶q,
·|µo²{§Y¨Ï¨S¥Îµ{¦¡ Load ©Î Show ·Ó¼Ë¨Ï¥ÎªºªÅ¶¡·|¸û¦h.
·íµMY Load ©Î Show ¤F«áªÅ¶¡·|¥Î§ó¦h. |
|
|
|
|
|
|