请问:如何将字符串按一个固定长度分割成多个字符串存入数组中?
日期:2006-12-11 荐:
请问:如何将字符串按一个固定长度分割成多个字符串存入数组中?例如:string="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"分割长度为5结果是:a(0)="aaaaa" a(1)="aaaaa" a(2)="aaaaa" ......for o=1 to int(len(string)/5)a(o)=mid(string,o,5)next oif (len(string) mod 5)>0 then a(o 1)=mid(string,len(string)-(len(string) mod 5),len(string)-int(len(string)/5))end ifstring=trim(replace(string,"aaaaa","aaaaa "))a=split(string)Dim str As String Dim a() As String Dim i As Integer ReDim a(0) str = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa" For i = 0 To Len(str) - 1 Step 5 a(i \ 5) = Mid(str, i 1, 5) ReDim Preserve a(UBound(a) 1) Nextdim shuzu() as stringshuzu = split(select * from c)shuzu(0)=selectshuzu(1)=*shuzu(2)=fromshuzu(3)=ck为长度i=0do i=i 1 p(i)=left(s$,k) if len(s)<=k then p(i)=s exit do end if s=mid(s,k 1)loop谢谢朋友们的帮忙!
标签: