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

½Ð±Ðmid¡Bmidb¡Blen¡Blenb°ÝÃD

¥»©«³Ì«á¥Ñ lionliu ©ó 2016-1-18 09:42 ½s¿è

¦^´_ 3# lionliu

ÁÂÁÂml¤j­ô¡A§Ú¦b´ú¸Õ¤@¤U¡C
lionliu

TOP

¦^´_ 3# lionliu

½Ð¬Ý³o½g»¡©ú
    http://forum.twbts.com/thread-31-1-1.html



Len ¨ç¼Æ½d¨Ò
²Ä¤@­Ó½d¨Ò¨Ï¥Î Len ¶Ç¦^¬Y¦r¦êªºªø«×(¦r¤¸¼Æ)©Î¬YÅܼƪº¤j¤p(¦ì¤¸¼Æ)¡CType...End Type µ{¦¡°Ï¶ô©w¸q¤@­Ó¦Û­q¸ê®Æ«¬ºA CustomerRecord¡C¦pªG¸Ó¸ê®Æ«¬ºA©w¸q¦bª«¥óÃþ§O¼Ò²Õ¤¤¡A«h¥²»Ý¥HÃöÁä¦r Private ¶}ÀY(ªí¥Ü¬°¨p¦³)¡C­Y©w¸q¦b¤@¯ë¼Ò²Õ¤¤¡AType ©w¸q´N¥i¥H¬° Public¡C

Type CustomerRecord    ' ©w¸q¨Ï¥ÎªÌ¦Û­qªº¸ê®Æ«¬ºA¡C
    ID As Integer    ' ±N¦¹©w¸q©ñ¦b¤@¯ë¼Ò²Õ¤¤¡C
    Name As String * 10
    Address As String * 30
End Type

Dim Customer As CustomerRecord    ' «Å§iÅܼơC
Dim MyInt As Integer, MyCur As Currency
Dim MyString, MyLen
MyString = "Hello World"    ' ³]©wÅܼƪì­È¡C
MyLen = Len(MyInt)    ' ¶Ç¦^ 2¡C
MyLen = Len(Customer)    ' ¶Ç¦^ 42¡C
MyLen = Len(MyString)    ' ¶Ç¦^ 11¡C
MyLen = Len(MyCur)    ' ¶Ç¦^ 8¡C

¦pªG¥ÎANSIªí¥Ü¦r¦êªº¸Ü¡A²Ä¤G­Ó½d¨Ò¨Ï¥Î LenB©M¨Ï¥ÎªÌ©w¸qªº¨ç¼Æ (LenMbcs) ¶Ç¦^¬Y¦r¦êªºªø«×(¦r¤¸¼Æ)¡C

Function LenMbcs (ByVal str as String)
    LenMbcs = LenB(StrConv(str, vbFromUnicode))
End Function

Dim MyString, MyLen
MyString = "ABc"
' "A" ©M "B" ¬O DBCS¥B "c" ¬OSBCS¡C
MyLen = Len(MyString)
' ¶Ç¦^¦r¦ê¤¤¦³3 ¡V3 ­Ó¦r¤¸¡C
MyLen = LenB(MyString)
' ¶Ç¦^ 6 ¡V 6 ¦ì¤¸¥Î©óUnicode¡C
MyLen = LenMbcs(MyString)
' ¶Ç¦^ 5 - 5­Ó¦ì¤¸¥Î©óANSI¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 2# ML089
ÁÂÁª©¤j¦^ÂÐ
§Úªº°ÝÃD¬Omidb(range,1,20)¬°¤°»ò­^¼Æ³£ºâÂù¦r¤¸¡C
§Úªº»Ý¨D¬O20¦r¤¸¡A­^¼Æ¤¤¤å²V¦X¡C
lionliu

TOP

¦^´_ 1# lionliu

§Aªº½d¨Ò¤¤ A1 = "abc123, abc 123 abc123§Ú·d¤£©w MID( ),MIDB( )¡ALEN( ) LENB( ) stuwxyz"

LEN(A1) = 64
LENB(A1) = 69
ªí¥Ü 69-64=5 ¦³5­ÓÂù¦r¤¸

¤£¤F¸Ñ§A­n¨D¬Æ»ò?
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

        ÀR«ä¦Û¦b : ¦³Ä@©ñ¦b¤ß¸Ì¡A¨S¦³¨­Åé¤O¦æ¡A¥¿¦p¯Ñ¥Ð¤£¼½ºØ¡A¬Ò¬OªÅ¹L¦]½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD