长字符串转为数组的处理
(创建时间:2011年10月20日 23:29:00)
Jangogo : 

今天更改以前一个同事做的模块的代码,运行效率之低让我很疑惑,没有可能编译的程序比Script程序还要慢

检查代码发现这个同事是这样写的:

 

VB
  1. For i = 0 To UBound( split( strMyList ,chr$(10) ) )  
  2.                 If Len(split( strMyList ,chr$(10) )(i)) < 1 Then Exit For  
  3.                 .InsertRowTexts lngDataRow, split( strMyList ,chr$(10) )(i)  
  4.                 '.......  
  5.             Next  

strMyList 在每一次循环都要 拆分为 数组 最少3次

当 strMyList 有一千行数据 ,处理起来就要几分钟,晕死人

应该先 定义一个数组 , 把字符串拆分一次即可

 

VB
  1. Dim aryList() as String  
  2. aryList=split( strMyList ,chr$(10)   
文档中心