[µo°Ý]¥HByte¬°³æ¦ì±N¦r¦ê¤©¥H°µ©î¤À¡A½Ð°ÝVBAn¦p¦ó³B²z¡H
- ©«¤l
- 132
- ¥DÃD
- 25
- ºëµØ
- 0
- ¿n¤À
- 199
- ÂI¦W
- 0
- §@·~¨t²Î
- window XP
- ³nÅ骩¥»
- Excel 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW ·s¦Ë
- µù¥U®É¶¡
- 2010-6-1
- ³Ì«áµn¿ý
- 2022-7-14
|
[µo°Ý]¥HByte¬°³æ¦ì±N¦r¦ê¤©¥H°µ©î¤À¡A½Ð°ÝVBAn¦p¦ó³B²z¡H
¦r¦êªºªø«×¬O 120 Ó Bytes
¦pªGn¨C60Ó Bytes n°µ¤@Ó¦r¦ê
´ú¸Õ¦r¦ê¦p¤U¡A¦@¬° 120 Ó Bytes
³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1
¥Øªº¬On©î¤À¦¨
³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1
³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1
¦ý¬O¥Î VBA ¼g¥X¨Ó·|Åܦ¨
³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1
³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1
³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1
VBA»~»{¬°
60=15(¤¤¤å¦r)*2+15(^¤å¦r¤]·|Åܦ¨2ÓByte)*2
60=15(¤¤¤å¦r)*2+15(^¤å¦r¤]·|Åܦ¨2ÓByte)*2
40=10(¤¤¤å¦r)*2+10(^¤å¦r¤]·|Åܦ¨2ÓByte)*2
¹ê»Ú¤W ¥»¤Hªº»{ª¾¬O
45=15(¤¤¤å¦r)*2+15*1
45=15(¤¤¤å¦r)*2+15*1
30=10(¤¤¤å¦r)*2+10*1 |
|
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 25
- ºëµØ
- 0
- ¿n¤À
- 199
- ÂI¦W
- 0
- §@·~¨t²Î
- window XP
- ³nÅ骩¥»
- Excel 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW ·s¦Ë
- µù¥U®É¶¡
- 2010-6-1
- ³Ì«áµn¿ý
- 2022-7-14
|
- Const Contatenate_Char = "_"
- Const Max_Length = 78
- '================================´ú¸Õ¤º®e========================================================================
- 'Hsiehª©¥D´ú¸Õ¤º®e¡A·|¦³ Bug
- '³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6
- '¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2
- '180="³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0"
- 'Max_Length = 78
- '³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°
- '_6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0³ü1
- '_¶L2°Ñ3¥|4¥î5³°6¤C7®Ã8¨h9¬B0
- Sub main()
- Call Process_Over_Length_XX(Test_String)
- End Sub
- Function If_ASCII_Stg(Stg_Test As String) As Boolean
- ' ´ú¸Õ¦r¤¸½X¬O§_¬°ASCII ¡A¦pªG¬O >= 0 ¥B <= 255 ®É¡A«h¬° ASCII
- ' ¦ý¬O¦r¤¸ªø«×¤j©ó 1®É¡Aµ{¦¡·|§ì²Ä1Ó¦r¤¸°µ§PÂ_
- If Asc(Stg_Test) >= 0 And Asc(Stg_Test) <= 255 Then
- If_ASCII_Stg = True
- Else
- If_ASCII_Stg = False
- End If
- End Function
- Sub Process_Over_Length_XX(Stg_Input As String)
- Dim Total_Pesudo_Char_Byte As Integer
- Dim Skip_1_or_2 As Byte, Current_Stg_Process_Position As Integer
- Dim Current_Stg As String, Ctr As Integer, Ctr_I As Integer
- Dim Counter_Stg_ProC_Bytes As Integer, Output_Stg As String
- Dim Line_1_Or_Not As Boolean
- Dim IS_ASCII_Boolean As Boolean
- ' ¦pªG¶W¹LNÓ¦r®É¡A´N¤À«e¬qªº³¡¤À
- ' ========== «Å§i¦r¦êÁ`ªø«× & ¦r¦ê²{¦b³B²zªº¦ì¸m ==========================
- Total_Pesudo_Char_Byte = Len(Stg_Input): Ctr = 0: Ctr_I = 0 '¥ý³]©w¬°ªÅ¦r¦ê & ¬°0
- Current_Stg_Process_Position = 1: Current_Stg = "" '¥ý³]©w¬°ªÅ¦r¦ê & ¬°0
-
- Do Until Ctr = Total_Pesudo_Char_Byte
- Do Until Counter_Stg_ProC_Bytes >= Max_Length - 1 Or Ctr = Total_Pesudo_Char_Byte ' ¦pªG¶W¹L Max Length ®É¡A´Nn¸õ¤U¤@Ó¦r¤¸
- Ctr = Ctr + 1
- Current_Stg = Mid(Test_String, Ctr, 1) ' ¦V«e±À¶i 1Ó¦r¤¸
- IS_ASCII_Boolean = If_ASCII_Stg(Current_Stg)
- Skip_1_or_2 = IIf(IS_ASCII_Boolean, 1, 2) ' n Skip ´XÓ Byte ¦pªG ¦r¤¸½X¬OASCII,«h ¸õ¹L ¦ì¤¸¼Æ¬°1 §_«h¬°2
- Counter_Stg_ProC_Bytes = Counter_Stg_ProC_Bytes + Skip_1_or_2
- ' ²{¦b¦b¨º¤@Ó String Byte ªº¦ì¸m
- If Counter_Stg_ProC_Bytes >= Max_Length And Not IS_ASCII_Boolean Then
- ' ¦pªG¤w¬O±µªñ¨C¦æªº (³Ì¤j¼Æ-1) ®É¡Anª`·N¬O§_¦³ ¥¿¦n¹J¨ì¤¤¤åor¥þ«¬¦r¡A¨Ï±o¥[2«á¡A·|¶W¹L1Ó¦r¡C
- Counter_Stg_ProC_Bytes = Max_Length: Ctr = Ctr - 1 '°h«á1Ó¦r ±j¨î¸õ¥X¦^°é¡A¥H³B²zªºByte ±j¨î¤Æ¬°³Ì¤jÈ
- End If
-
- Loop
- Output_Stg = Mid(Stg_Input, Current_Stg_Process_Position, Ctr - Current_Stg_Process_Position + 1)
- Debug.Print (Output_Stg)
- Current_Stg_Process_Position = Ctr + 1
- Counter_Stg_ProC_Bytes = 0 ' ¤©¥HÂk 0
- Loop
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 25
- ºëµØ
- 0
- ¿n¤À
- 199
- ÂI¦W
- 0
- §@·~¨t²Î
- window XP
- ³nÅ骩¥»
- Excel 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW ·s¦Ë
- µù¥U®É¶¡
- 2010-6-1
- ³Ì«áµn¿ý
- 2022-7-14
|
Hsieh ª©¥D
³oÓ¸ò§Úì¨Ó·Qªº°µªk¡A¤è¦¡¤jP¬Û¦P¡C
·Q»¡¬Ý¦³µL¤ñ¸û¦nªº¤èªk°µ¡C
³o¼Ë¬Ý¨Ó¦³¨Ç¥Î¡u¼É¤O¡v¸ÑÃD¡C
¬Ý¨Ó VBA ¤]¨S¦³¨ä¥L¨ç¼Æ¤ñ¸û¦n¥Î¡C
[è«öªº¤Ó§Ö]
Ex:
Max_Length=4
³ü1¶L1°Ñ1
³ü1¶L ¹ê»Ú¬O5Ó Byte
Do Until s = Max_Length
³o¼Ë·|¸ó¹L¤@Ó¦r¡C
ª©¥D¡A³oÓ Bug §Ú·Q§Ú¥i¥H¦Û¦æ¸Ñ¨M¡C
¦pªG¦³·sªº VBA Defalult Function ªº¸Ü¡A¦A§i¶D¡C |
|
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 25
- ºëµØ
- 0
- ¿n¤À
- 199
- ÂI¦W
- 0
- §@·~¨t²Î
- window XP
- ³nÅ骩¥»
- Excel 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW ·s¦Ë
- µù¥U®É¶¡
- 2010-6-1
- ³Ì«áµn¿ý
- 2022-7-14
|
¦³´ú¸Õ¹L¡AÃä¬ÉÈ·|¦³°ÝÃD
Bug ·|²£¥Íªº±¡ªp
n¸ó¹L Max_Length ®É¡A¥¿¦n¹J¨ì¤¤¤åor¥þ«¬¦r¡C
Ex:
Max_Length=4
³ü1¶L1°Ñ1
³ü1¶L ¹ê»Ú¬O5Ó Byte
Do Until s = Max_Length
¦]¬°¦pªG |
|
|
|
|
|
|
- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 247
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-14
|
¦^´_ 3# Baracuda
³Ìª½±µªº¤èªk¬O§PÂ_¦r¤¸½X¨Ó¨M©w¦r¤¸ªº¦ì¤¸¼Æ- Sub ex()
- Dim k&, t%, i%, c%, s%
- k = Len(Test_String)
- t = 1
- Do Until i = k
- Do Until s = Max_Length
- i = i + 1
- c = Asc(Mid(Test_String, i, 1))
- s = s + IIf(c >= 0 And c <= 255, 1, 2) '§PÂ_¦r¤¸½X¬O§_¬°ASCII,¬O«h¦r¤¸ªº¦ì¤¸¼Æ¬°1§_«h¬°2
- Loop
- MsgBox Mid(Test_String, t, i - t + 1)
- t = i + 1
- s = 0
- Loop
- End Sub
½Æ»s¥N½X |
|
¾Ç®üµL²P_¤£®¢¤U°Ý
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 25
- ºëµØ
- 0
- ¿n¤À
- 199
- ÂI¦W
- 0
- §@·~¨t²Î
- window XP
- ³nÅ骩¥»
- Excel 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW ·s¦Ë
- µù¥U®É¶¡
- 2010-6-1
- ³Ì«áµn¿ý
- 2022-7-14
|
ªþ¤Wµ{¦¡¤º®e¥H§K¦³µLªk¤U¸üªº°ÝÃD |
|
|
|
|
|
|
- ©«¤l
- 132
- ¥DÃD
- 25
- ºëµØ
- 0
- ¿n¤À
- 199
- ÂI¦W
- 0
- §@·~¨t²Î
- window XP
- ³nÅ骩¥»
- Excel 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW ·s¦Ë
- µù¥U®É¶¡
- 2010-6-1
- ³Ì«áµn¿ý
- 2022-7-14
|
¥»©«³Ì«á¥Ñ Baracuda ©ó 2013-4-4 23:08 ½s¿è
- Option Explicit
- Option Base 1
- Const Max_Length = 60
- Const Test_String = "³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1"
- ' 30 ªø«× "³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1"
- ' 120 ªø«× "³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1"
- Sub main()
- Call Process_Over_Length_XX_Byte(Test_String)
- End Sub
- Sub Process_Over_Length_XX_Byte(Stg_Input As String)
- ' ±N©Ò¿é¤Jªº¦r¦ê¡A¦pªG¶W¹L60Ó Byte «á¡A¤©¥H¤À¬° N¦C , Max_Length =60
- Dim Total_Char_Byte As Integer, Total_Line_Output As Integer, i As Integer, CountDown_No As Integer
- Dim First_Max_Length_Stg As String, Tmp_Integer As Integer
- Total_Char_Byte = LenB(Stg_Input)
- Total_Line_Output = 1 + Int(Total_Char_Byte / Max_Length)
- ' Á`¦@¦³´XÓ Line n³B²z Max_Length = 60
- CountDown_No = Total_Line_Output
-
- For i = 1 To Total_Line_Output
- If CountDown_No = 1 Then
- ' ¦pªG¬O³Ì«á¤@¦C®É¡A§Y¬O³Ì«á¤@¦¸¿é¥X
- Debug.Print (Stg_Input)
- Exit Sub
- Else
- ' ¦pªG¤£¬O³Ì«á¤@¦C®É¡ACountDown_No ªº¼Æ¦r§Y´î 1
- CountDown_No = CountDown_No - 1
- First_Max_Length_Stg = LeftB(Stg_Input, Max_Length) 'Max_Length = 60
- Tmp_Integer = LenB(First_Max_Length_Stg)
- Debug.Print First_Max_Length_Stg
- Stg_Input = RightB(Stg_Input, LenB(Stg_Input) - Max_Length)
- ' ±N¦r¦ê¤©¥H«¸m¡A¥h°£«e¤è60 Ó¦r¤¸ Max_Length = 60
- Tmp_Integer = LenB(Stg_Input)
- End If
- Next i
- End Sub
½Æ»s¥N½X Option Explicit
Option Base 1
Const Max_Length = 60
Const Test_String = "³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1"
' 30 ªø«× "³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1"
' 120 ªø«× "³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1³ü1¶L1°Ñ1¥|1¥î1³°1¤C1®Ã1¨h1¬B1"
Sub main()
Call Process_Over_Length_XX_Byte(Test_String)
End Sub
Sub Process_Over_Length_XX_Byte(Stg_Input As String)
' ±N©Ò¿é¤Jªº¦r¦ê¡A¦pªG¶W¹L60Ó Byte «á¡A¤©¥H¤À¬° N¦C , Max_Length =60
Dim Total_Char_Byte As Integer, Total_Line_Output As Integer, i As Integer, CountDown_No As Integer
Dim First_Max_Length_Stg As String, Tmp_Integer As Integer
Total_Char_Byte = LenB(Stg_Input)
Total_Line_Output = 1 + Int(Total_Char_Byte / Max_Length)
' Á`¦@¦³´XÓ Line n³B²z Max_Length = 60
CountDown_No = Total_Line_Output
For i = 1 To Total_Line_Output
If CountDown_No = 1 Then
' ¦pªG¬O³Ì«á¤@¦C®É¡A§Y¬O³Ì«á¤@¦¸¿é¥X
Debug.Print (Stg_Input)
Exit Sub
Else
' ¦pªG¤£¬O³Ì«á¤@¦C®É¡ACountDown_No ªº¼Æ¦r§Y´î 1
CountDown_No = CountDown_No - 1
First_Max_Length_Stg = LeftB(Stg_Input, Max_Length) 'Max_Length = 60
Tmp_Integer = LenB(First_Max_Length_Stg)
Debug.Print First_Max_Length_Stg
Stg_Input = RightB(Stg_Input, LenB(Stg_Input) - Max_Length)
' ±N¦r¦ê¤©¥H«¸m¡A¥h°£«e¤è60 Ó¦r¤¸ Max_Length = 60
Tmp_Integer = LenB(Stg_Input)
End If
Next i
End Sub |
|
|
|
|
|
|