28、程序运行时间统计
Sub test()
begin_time = Timer
For i = 1 To 1000
For j = 1 To 10000
x = x + 1 * 2
Next
Next
end_time = Timer
MsgBox "运行用时" & Format(end_time - begin_time, "0.00")
End Sub
29、split函数及join函数
split函数用于分割字符串并返回一个下标从0开始的数组,它包含指定的自字符串数目
Dim direc
Set direc = CreateObject("Scripting.Dictionary")
contents = Split(Content, ",") ‘分割符为逗号
For k = LBound(contents) To UBound(contents)
direc(contents(k)) = direc(contents(k)) + 1
Next
Key = direc.Keys
Value = direc.items
[B1].Resize(direc.Count, 1) = Application.Transpose(Key)
[C1].Resize(direc.Count, 1) = Application.Transpose(Value)
jion函数返回一个字符串,该字符串通过连接某个一维数组的多个自字符串而创建的
arr = [{"武汉","广州","深圳"}]
res = Join(arr, ";") '得到武汉;广州;深圳
30、filter函数
filter函数返回一个下标从零开始的数组,该数组包含基于指定筛选条件的一个字符串数组的子集。语法如下:
Filter(sourcesrray, match[, include[, compare]])
Filter函数语法有如下的命名参数:
部分 |
描述 |
sourcearray |
必需的。要执行搜索的一维字符串数组。 |