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

[Âà¶K] Len / LenB - ¦r¦êªø«×§PÂ_¤è¦¡ªº±´°Q

[Âà¶K] Len / LenB - ¦r¦êªø«×§PÂ_¤è¦¡ªº±´°Q

¤@¯ë»{ª¾¤W¡ALenB¬O¶Ç¦^¦ì¤¸²Õªºªø«×¡A
¦p¦¹¹ï©óÂù¦ì¤¸¤å¦r¦p¤¤¤å¡B¥þ§Î¦rµ¥¡A
§Ú­Ì¥i¨ú±o¦r¤¸(Byte)¼Æ¦Ó¤£¬O¦r¼Æ¡C¨Ò¦p¡G
mystr = "´ú¸Õ"
Len(mystr) --> 2
LenB(mystr) --> 4

VBA¨ç¼Æ LenB »P¤u§@ªí¨ç¼Æ LENB ªº®t²§
¤W­z¨Ò¤l§ï¨Ï¥Î¤u§@ªíªº LENB ¥ç¥i±o¨ì¬Û¦Pªºµ²ªG¡C
¦A¬Ý¥H¤U¨Ò¤l¡G
¤u§@ªí LEN("ABC") --> 3
¤u§@ªí LENB("ABC") --> 3
VBA Len("ABC") --> 3
VBA LenB("ABC") --> 6
§A¥i¯àı±o©_©Ç¡A"ABC"¤£¬O¥b§Î¦r¶Ü¡A
¬°¦óVBA LenB «o¶Ç¦^ 6 ©O?
¬°¦óVBA LenB ©M¤u§@ªí LENB ¶Ç¦^¤£¦Pµ²ªG?

¥ý¬Ý¥H¤U¦A»¡¡G
LenB(StrConv("ABC",vbFromUnicode)) --> 3

³z¹L StrConv Âà´«¡ALenB §Y¶Ç¦^§Ú­Ì¹w´Áªºµ²ªG¡C
VBA»²§U»¡©ú¨S¦³©ú½Tªº¸ÑÄÀ LenB ªº³B²z­ì«h¡A
¦ý¥Ñ¦¹¥i±À´ú VBA LenB ¬O±N¦r¦ê¥H Unicode ½s½X¤è¦¡³B²z¡A
¦Ó¤@­ÓUnicode¦r¤¸¬O¦û¨â­Ó¦ì¤¸²Õ¡C

µù1¡G½Ð°Ñ¾\VBAªº StrConv ¨ç¼Æ»¡©ú¡C
µù2¡G´ú¸ÕÀô¹Ò¦p¥ª¡A¨ä¥Lª©¥»­Y¦³¤£¦P¡A½Ð´£¥X¨Ñ¤j®a°Ñ¦Ò~

¦³®É­Ô¦r¦ê¸Ì­±¥]§t¤FªÅ®æ·|¼vÅTlen¨ç¼Æªº§PÂ_
¥i¥H¥ý¥Îtrim¥h°£ªÅ®æ ´N¯à½T«O ¦r¦ê¤£§tªÅ®æ

TOP

¦^´_ 1# Hsieh

·PÁª©¥Dªº¤À¨É»¡©ú.....
§Ú¬O±q Google ·j´M¦n¤[¤~µo²{¡A­ì¨Ó¦b³o­Ó°Q½×°Ï´N¦³³o­Ó±´°Q¸ê®Æ....
¯u¬O±Ëªñ¨D»·.....

TOP

¤@¯ë»{ª¾¤W¡ALenB¬O¶Ç¦^¦ì¤¸²Õªºªø«×¡A
¦p¦¹¹ï©óÂù¦ì¤¸¤å¦r¦p¤¤¤å¡B¥þ§Î¦rµ¥¡A
§Ú­Ì¥i¨ú±o¦r¤¸(Byte)¼Æ¦Ó ...
Hsieh µoªí©ó 2010-5-1 09:03




§Ú¸Õ¹L¨â³¡¹q¸£¾Þ§@¸Óµ{¦¡¡A¤@³¡¥i¥H¡A¥t¤@³¡¤£¥i¥H¡C
Microsoft 365 office ¦n¹³¤£¦æ¡C

TOP

¦^´_ 1# Hsieh



§Ú¸Õ¹L¨â³¡¹q¸£¾Þ§@¸Óµ{¦¡¡A¤@³¡¥i¥H¡A¥t¤@³¡¤£¥i¥H¡C
Microsoft 365 office ¦n¹³¤£¦æ¡C

TOP

¦^´_ 5# 198188


¸Õ¸Õ¥H¤U¤èªk
T = "123"
MsgBox Evaluate("LenB(""" & T & """)")
T = "¢°¢±¢²"
MsgBox Evaluate("LenB(""" & T & """)")

TOP

¦^´_ 6# ­ã´£³¡ªL

´ú¸Õµ²ªG¦p¤U¡G

T = "123"
MsgBox Evaluate("LenB(""" & T & """)")  = 3
T = "¢°¢±¢²"
MsgBox Evaluate("LenB(""" & T & """)")  = 5
T = "§Ú¢±¢²"
MsgBox Evaluate("LenB(""" & T & """)")  = 6
T = "A123"
MsgBox Evaluate("LenB(""" & T & """)") = 4

¤£¹Lµo²{¥t¤@ºØ±¡ªp¡A¦pªG¬O10¦ì¼Æ¦r¡A®ÄªG¤S¦³°ÝÃD¡A LENB =18¡A¦p¤U¹Ï

TOP

¦^´_ 7# 198188

T = "¢°¢±¢²"  ³o¬O¥þ«¬¦r
MsgBox Evaluate("LenB(""" & T & """)")  = 5
¥i¬O¬Ý¹Ï¤ù, ¦n¹³¬O ¥b«¬123¥[¨â­ÓªÅ®æ..."1 2 3"

TOP

¦^´_ 8# ­ã´£³¡ªL



¥i¯à¹Ï¤ù¦³»~¸Ñ¡A¡§1 2 3¡¨ ªº³¡¤À¨S°ÝÃD¡C
¬OÀY¤T­Ó¦³°ÝÃD¡C
²Ä¤@­Ó§Úª½±µ¦bVBAùؼg T="2402290011"  µM«á¥ÎLENB("""&T&""") =±o¥Xµª®×¬O10
²Ä¤G­Ó§Ú¦bExcel ªí®æB16 ùØ¥´¤F 2402290011  ,T = Àx¦s®æB16¡AµM«á¥ÎLENB("""&T&""") = ±o¥Xµª®×¬O18
²Ä¤G­Ó§Ú¦bExcel ªí®æB16 ùØ¥´¤F 2402290011  ,T = Àx¦s®æB16¡AµM«á¥ÎLEN(T) = ±o¥Xµª®×¬O10
¥i¥H°Ñ¬Ý¤W¹Ï

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¨S¦³©Ò¦³Åv¡A¥u¦³¥Í©Rªº¨Ï¥ÎÅv¡C
ªð¦^¦Cªí ¤W¤@¥DÃD