本帖最后由 manlty 于 2010-6-8 08:03 编辑
下面这个vbs函数是将附件中的文件数据转为txt文档数据的,请转码为au3的函数Sub PoboToFoxtraderTXT(strFile,fileName,dateNum)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim objStream, fso, jiaGe(10)
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1
objStream.Open
objStream.LoadFromFile strFile
If dateNum=0 Then
dateNum= objStream.Size/32
ElseIf dateNum < objStream.Size/32 Then
dateNum=dateNum
Else
dateNum=objStream.Size/32
End If
objStream.position = objStream.Size-dateNum*32
For i = 1 To dateNum
readFile = AscB(objStream.Read(1))+AscB(objStream.Read(1))*256+AscB(objStream.Read(1))*256*256+AscB(objStream.Read(1))*256*256*256
nian = readFile\1048576
yue = readFile\65536-nian*16+100
ri = (readFile Mod 65536)\256\8+100
riQi = CStr(nian)+"/"+Right(CStr(yue),2)+"/"+Right(CStr(ri),2)
For j = 1 To 4
readFile = AscB(objStream.Read(1))+AscB(objStream.Read(1))*256+AscB(objStream.Read(1))*256*256+AscB(objStream.Read(1))*256*256*256
jiaGe(j) =CStr(readFile/1000)+" "
Next
objStream.position = objStream.position+12 '成交量和持仓量数据结构未知,暂时不导出!
shuChu = shuChu+riQi+" "+jiaGe(2)+jiaGe(3)+jiaGe(4)+jiaGe(1)+vbCrLf
riQi=""
Next
objStream.Close
Set objStream = Nothing
Set fso=CreateObject("Scripting.FileSystemObject")
If fso.FolderExists("C:\TXTDAY") Then
i=0
Else
fso.CreateFolder ("C:\TXTDAY")
End If
Set MyFile=fso.OpenTextFile(fileName,ForWriting,True,TristateFalse)
MyFile.WriteLine shuChu
MyFile.close
Set MyFile = Nothing
Set fso = Nothing
End Sub
|