那天无意中搜到一篇名为《我为什么喜欢VBS和C?》的文章,里面引用了《VBS和C语言效率比较》中的程序。
Option Explicit
Dim begin_time,end_time,elapse_time
Dim str,length,i,c
Dim ado,fso,file
begin_time = Timer
Set ado = CreateObject("adodb.stream")
Set fso = CreateObject("scripting.filesystemobject")
Set file = fso.OpenTextFile("foo.txt",2,True)
ado.Type = 1
ado.Open
ado.LoadFromFile("foo.jpg")
str = ado.Read
length = LenB(str)
For i = 1 To length
c = AscB(MidB(str,i,1))
file.WriteLine c & "," & "_"
Next
ado.Close
end_time = Timer
elapse_time = end_time - begin_time
WScript.Echo elapse_time
时隔半年多再看这段代码,实在没有什么效率可言。正如有人在《用VBS读写二进制文件》中的回复:
(更多…)