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

·s¤âµo°Ý - ½Ð°Ý

·s¤âµo°Ý - ½Ð°Ý

·s¤â­n¾ÇExcel VBA »Ý­n¥ý¥Ñ¨º³¡¤À¾Ç°_©O?
¦³¥h¨¦ºq¤F¤@¨Çºô¯¸
¦ý¬O¥ú Dim («á­±¤@°ï©R¦W´N·d¤£À´¤F)
Ex: Dim x as long
     Dim x as integater
     Dime arr()
³o¬Ovba ¶}ÀY¤@©w­n°µªºªF¦è¶Ü??

¦^´_ 7# alex_wu

1.©Ò¥H­Y­n¥[§Öµ{¦¡³t«×, ©Ò¥H«Å§i®É ,­Y¨Ï¥Î¤§Data ¤£·|¶W¹L65536µ§
    «h¥ÎDim x as integer ¸û¨Î.¹ï¶Ü?
2.½Ð°Ý¥H¤U»{ª¾¹ï¶Ü ?
Dim arr(x) as Variant  --> «ü©w¸q°}¦Cxªº¸ê®Æ¬° ?? Variant¬O??
Dim arr(x) as string    --> «ü©w¸q°}¦Cxªº"¤º®e"¬°"¦r¦ê"
Dim arr(x) as integer  --> «ü©w¸q°}¦CXªº"¤º®e"¬°"¼Æ­È"
------------------------------------------------------------------------
·Pı¦³ÂI©Ç©Çªº.
X ¬°¾ã¼Æ­È, ¨ä­Èªº½d³ò¬° -32768 ~ 32767
¥i¥H³o¼Ë¤l«Å§i
Const  X as Integer = 32767
Dim Arr(x) as String    ' °}¦C¯Á¤Þ½d³ò¬° 0~32766
©ÎªÌ
Dim Arr(1 to X) as String ' °}¦C¯Á¤Þ½d³ò¬° 1  ~ 32767

­Y±z·Q¦bµ{¦¡½X¤¤, ©Ò«Å§iªº°}¦C, ¬O¥Ñ 1 ¶}©l, ¦Ó¤£¬O 0 ¶}©l,
½Ð¦b³Ì¤W­±¥[¤W¤@¦æ Option Base 1

TOP

¶â,ÁÂÁÂ,¹ï«Å§i¦³°ò¦ªº»{ª¾¤F
¥i¬O¬°¤°»ò­n§â¸ê®Æ¥á¨ì°}¦C¸Ì©O?
ª½±µ§âÀx¦s®æ¤ºªº¸ê®Æ¹Bºâ¤£¬O¸û§Ö¶Ü?
...
alex_wu µoªí©ó 2012-5-31 22:23


1. Excel ¤u§@ªí, ¥»¨­´N¬O¤@­Ó¤j«¬ªº ¤Gºû°}¦C.
   ¦ý¥¦¨C¤@­ÓÀx¦s®æ, ¤£©w¤j¤p, ¥i¦s©ñ¦UÃþ«¬ºAªº¸ê®Æ»P¬ÛÃöÄÝ©Ê, ¬G¬Û¹ï¦Ó¨¥, ¬O¤ñ ³æ¤@«¬ºAªº°}¦C, ¯Ó¥Î§ó¦hªº°O¾ÐÅé.
   ÀuÂI: ¥iµø¤Æ

2. VBA ¤ºªº³æ¤@«¬ºA°}¦C, ¦bµ{¦¡°õ¦æ®É, ¨ä³t«×, »·¤ñ¦A¥h½Õ¥Î ¤u§@ªíªºÀx¦s®æ¸ê®Æ, ÁÙ­n¨Óªº§Ö.

TOP

ÁÂÁ¤ÀªR,­ì¨Ó°}¦Cªº¦n³B¬O°}¦C©Ò¥eªº¸ê·½¸û¤Ö.§Ú·Q·N«ä
À³¸Ó¬O-->°}¦C¦³¤@ÂI¹³¬O¶}¤F¥t¤@­Ó¤u§@ªí¨Ó¶i¦æ¹Bºâ.
(¦ý¹ê»Ú¬O³z¹L°}¦C¤º¸ê®Æ+¤½¦¡¶i¦æ¹Bºâ) ¬ðµM¦³ÂIÀ´¤F
ÁÂÁ¦U¦ì¤j¤j. (¹ï§Ú­Ì·s¤â¦Ó¥B,ÁÙ¬O¥ý¼ô±x­¶­±Àx¦s®æ¹Bºâ
¦A¤Á¤JVBAÀ³¸Ó¸û§Ö)
¤U¤@¶¥¬q¦A¬D¾Ô¬Ý¬Ý¥Ñ²©öªº¿ý»s¥¨¶° + °j°é¸Õ¸Õ , ÁÂÁ¤j®a

TOP

¶â,ÁÂÁÂ,¹ï«Å§i¦³°ò¦ªº»{ª¾¤F
¥i¬O¬°¤°»ò­n§â¸ê®Æ¥á¨ì°}¦C¸Ì©O?
ª½±µ§âÀx¦s®æ¤ºªº¸ê®Æ¹Bºâ¤£¬O¸û§Ö¶Ü?
...
alex_wu µoªí©ó 2012-5-31 22:23



¥i¬O¬°¤°»ò­n§â¸ê®Æ¥á¨ì°}¦C¸Ì©O?
ª½±µ§âÀx¦s®æ¤ºªº¸ê®Æ¹Bºâ¤£¬O¸û§Ö¶Ü?

§Ú¤]Æg¦¨ºÉ¶q§â¸ê®Æ©ñ¦b­¶­±Àx¦s®æ¤W³B²z,
°}¦C³q±`¬O¥Î¨Ó§@¼È®É¦ì¸m,¤£¥Î§ä­Ó­¶­±¨Ó¥Î.
¨Ò¦p§â¤å¦r¤À©î
arr= split("ABC;DEF;GHG",";")->
arr(0) ·|Åܦ¨ABC
arr(1) ·|Åܦ¨DEF
arr(2) ·|Åܦ¨GHG

¥t¥~°Ý¤@¤U,¾Ç¤F«Å§i(Dim)¤§«á,¤U¤@¶¥¬q»Ý­n¾Ç¤°»ò©O?
¥i¥H¬Ý¤@¤U function/sub,  for/next, loop/while,
excel¬ÛÃöªº¬ORANGE() ªº¥Îªk.
³Ì²³æ¬O±q¿ý»s¥¨¶°¤¤¾Ç²ß.
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

¦^´_ 9# alex_wu
¥i¬O¬°¤°»ò­n§â¸ê®Æ¥á¨ì°}¦C¸Ì©O? ª½±µ§âÀx¦s®æ¤ºªº¸ê®Æ¹Bºâ¤£¬O¸û§Ö¶Ü?
¹Ï1  ¸ê®Æ¦s¦bÀx¦s®æ¤ºªº©Ò¦ûªº¸ê·½
   

¹Ï2  ¸ê®Æ¦s¦b°}¦Cªº©Ò¦ûªº¸ê·½

TOP

¶â,ÁÂÁÂ,¹ï«Å§i¦³°ò¦ªº»{ª¾¤F
¥i¬O¬°¤°»ò­n§â¸ê®Æ¥á¨ì°}¦C¸Ì©O?
ª½±µ§âÀx¦s®æ¤ºªº¸ê®Æ¹Bºâ¤£¬O¸û§Ö¶Ü?

¥t¥~°Ý¤@¤U,¾Ç¤F«Å§i(Dim)¤§«á,¤U¤@¶¥¬q»Ý­n¾Ç¤°»ò©O?

TOP

1.©Ò¥H­Y­n¥[§Öµ{¦¡³t«×, ©Ò¥H«Å§i®É ,­Y¨Ï¥Î¤§Data ¤£·|¶W¹L65536µ§
    «h¥ÎDime x as integer ¸û¨Î.¹ï¶Ü ...
alex_wu µoªí©ó 2012-5-31 13:26


1. ¹ï. ¦pªG¥u¬O¤Q¼Æ­ÓÅܶq,³o­Ó¦~¥Nªº¹q¸£,³t«×¤À§O¤£·|«Ü¤j

2.
VARIANT ªº·N«ä¬O¥ô·NÃþ«¬, ¥Ñexcel¦Û¤v¥Ñ¤º®e³]©wÃþ«¬
dim abc as variant
abc = 123
³o¼ËabcªºÃþ«¬´N·|Åܦ¨ "variant/integer" §Yinteger

dim abc as variant
abc = "def"
abcªºÃþ«¬´N·|Åܦ¨ "variant/string"

Dim arr(x) as integer
¤£¬O"°}¦Cx", ¦Ó¬O¦³ X+1 ­Ó­Èªº"°}¦CARR"
¨Ò¦p
Dim abc(3) as integer
¸ò³o4¦æÃþ¦ü
Dim abc1 as integer
Dim abc2 as integer
Dim abc3 as integer
Dim abc4 as integer

³]©w¼Æ­È®É:
abc(0)=1
abc(1)=2
abc(2)=3
abc(3)=4
¬Û¹ï©ó
abc1=1
abc2=2
abc3=3
abc4=4
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

1.©Ò¥H­Y­n¥[§Öµ{¦¡³t«×, ©Ò¥H«Å§i®É ,­Y¨Ï¥Î¤§Data ¤£·|¶W¹L65536µ§
    «h¥ÎDime x as integer ¸û¨Î.¹ï¶Ü?
2.½Ð°Ý¥H¤U»{ª¾¹ï¶Ü ?
Dim arr(x) as Variant  --> «ü©w¸q°}¦Cxªº¸ê®Æ¬° ?? Variant¬O??
Dim arr(x) as string    --> «ü©w¸q°}¦Cxªº"¤º®e"¬°"¦r¦ê"
Dim arr(x) as integer  --> «ü©w¸q°}¦CXªº"¤º®e"¬°"¼Æ­È"

TOP

Long ¥i¦sÀxªº¼Æ­È ½d³ò, ¤ñ Integer  ¤j¤W³\¦h,
¬Û¹ï¨Ó»¡, ¹Bºâ³t«×¤]¤£¤Î Integer ©Ò«Å§iÅܼƨӪº§Ö.
Integer  2 ­Ó¦ì¤¸²Õ -32,768 ¨ì 32,767
Long (long integer) 4 ­Ó¦ì¤¸²Õ -2,147,483,648 ¨ì 2,147,483,647
--------------------------------------------------------------------
Dimarr(x)   
¥i¥H³o¼Ë¤l«Å§i, ¦ý¤£«Øij.
«Øij«á¤è ¦A©w¸q¨ä¸ê®Æ«¬ºA
¨Ò¦p:
Dim arr(x) as Variant
Dim arr(x) as string
Dim arr(x) as integer

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡µLªk¾B¾×¡j©È®É¶¡®ø³u¡Aªá¤F³\¦h¤ß¦å¡A·QºÉ¦U¦¡¤èªk­n¾B¾×®É¶¡¡Aµ²ªG¬O¡G®ö¶O¤F§ó¦h®É¶¡¡A¥B¤@µL©Ò¦¨¡I
ªð¦^¦Cªí ¤W¤@¥DÃD