发新话题
打印

len(),lift(),right()不能正常识别中文的解决方法

len(),lift(),right()不能正常识别中文的解决方法


以下用法和len(),lift(),right()一样。
* T7 H) C+ G  {- _: W
" ]. r- w% n( w0 b  O  & S9 W* k+ t2 k6 Y
" ~' S6 H2 x7 Y
Function Strlength(Str)) |4 L( }8 T) _2 U* H9 [# v
Temp_Str=Len(Str)
; ~9 Y- G' S2 i/ F2 S+ D9 ~; BFor I=1 To Temp_Str. C9 V) n$ ?" O" X. d* y
Test_Str=(Mid(Str,I,1))5 ^4 P9 M5 f5 o
If Asc(Test_Str)0 Then
) \. T' u$ S) g' V5 J3 jStrlength=Strlength 1
9 j( s# m, B8 f% ]9 kElse
  W5 s; e1 Z0 a: Q( T( h* XStrlength=Strlength 2
' g0 T1 R- I; xEnd If
3 r( D0 p( k3 n/ J; N3 P/ SNext
" e& K4 s* c- IEnd Function
, z  |  v/ u: y+ ]2 I4 gFunction Strleft(Str,L)
! m  R, v5 Q' {" A0 ETemp_Str=Len(Str)# K& u" K. \2 _
For I=1 To Temp_Str
) A5 p1 M. [3 X* O9 J" U' j+ R) tTest_Str=(Mid(Str,I,1))4 H( z& n# T' T, F
Strleft=StrleftTest_Str( u; h& j, q! v% h3 \1 H
If Asc(Test_Str)0 Then
# ]6 k. R, H6 f, ]  {! ~# zlens=lens 1( Y6 l3 T3 I4 o; `- Y& O
Else* c, J) j! B: s6 z( W
lens=lens 2
3 k. ]) K5 w# O6 QEnd If
9 E- w8 @' N+ o" @) |If lens=L Then Exit For
$ l  e, q+ I3 b) Y/ \Next
# S- ~3 E+ K1 s! b, f1 @End Function
) L, U" Y4 M' f9 aFunction Strright(Str,L)
2 `6 T8 n' U1 mTemp_Str=Len(Str)
6 x, n. w4 W6 WFor i = Temp_Str to 1 step -1, a" m/ e7 x% d7 F: P9 U
Test_Str=(Mid(Str,I,1))* W0 B, E& T' [5 Q! q
Strright=Test_StrStrright3 `) @' r  [8 X8 s' Q7 X# I
If Asc(Test_Str)0 Then
# C8 m. H2 k+ Z  _lens=lens 1. k1 C# E+ S- r
Else
7 S* V6 w2 |: h% |7 @$ @% l  Rlens=lens 24 V2 d- \9 o- z
End If+ q* j) O2 o5 w) e2 ^" _, G0 c$ x
If lens=L Then Exit For
+ }: `* ?. J% G. ^: {# ?! \& QNext
3 w7 _( W5 i( p( `7 w' k1 sEnd Function



点击图标进入精品网摘收藏 欢迎大家加入网络收藏夹

TOP

发新话题